How to change the way that vim display those collapsed/folded lines(show hidden line numbers at line tail but not head). I have googled and sited vim wiki, but found no hints.
please see the picture [more pretty vim fold format]
the fold style is just like the right hand side of the pic.
You can set your function to set the fold text
Try something like this:
function! MyFoldText()
let nblines = v:foldend - v:foldstart + 1
let w = winwidth(0) - &foldcolumn - (&number ? 8 : 0)
let line = getline(v:foldstart)
let comment = substitute(line, '/\*\|\*/\|{{{\d\=', '', 'g')
let expansionString = repeat(".", w - strwidth(nblines.comment.'"'))
let txt = '"' . comment . expansionString . nblines
return txt
endfunction
set foldtext=MyFoldText()
v:foldend
line number of last line in the fold
v:foldstart
line number of first line in the fold
nblines
is computed doing the diff and add 1
Then the comment is extracted removing the marker, should be improved using comment sign of the syntax and folding marker selected.
The expansionString
is computed based on the winwidth
You can find the documentation here: http://vimdoc.sourceforge.net/htmldoc/fold.html#fold-foldtext
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With