On 01/15/2012 10:42 AM, Guido Van Hoecke wrote:
Hi,
I want to write a foldtext function where the folded block would not
have the standard +- header with variable nr of dashes, but the exact
text appearing before the fold marker (in casu one or more '{' possibly
followed by a digit). Here it is:
function! MyFoldText() " show the text before the fold marker
let nr = v:foldend - v:foldstart + 1
let line = getline(v:foldstart)
let txt = substitute(line, '{\+\d\=', '('.nr.' lines)', 'g')
return txt
endfunction
I am expecting erm... hoping that this would preserve the initial
whitespace: a line '\t\t\tsomeText {' would then be displayed as
a folded block with the text '\t\t\tsomeText (nn lines)'.
It is not. I know that the help for 'foldtext' explicitely states
'...Leading white space, "//" or "/*" and the text from the 'foldmarker'
and 'commentstring' options is removed. ...'
I was hoping that this comment only applied to the default foldtext
function, but it seems that that is not the case. I would have liked to
have full control over the displayed foldtext.
Is this at all possible?
If so, I'd like to see how it's done.
If it is not the case, wouldn't that be a desirable feature?
With my current indented folded blocks are outdented and
completely break the visual indentation view, such a pitty.
Kind regards,
Guido
--
I must get out of these wet clothes and into a dry Martini.
-- Alexander Woolcott
http://vanhoecke.org ... and go2 places!
It does work for me but I'm dealing with lines that have
leading spaces and I add leading spaces, here is a relevant
snip:
let l = getline(v:foldstart)
let line = substitute(l, '^[ ]*', '', '')
let prefix = repeat(' ', (strlen(l) - strlen(line)))
let c = ''
if l =~ '^\s*class\s' | let c = '(c)--' | endif
let line = prefix . '+--' . c . ' ' . line
-ak
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php