Skip to content

Instantly share code, notes, and snippets.

@kshenoy
Last active April 21, 2019 06:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kshenoy/5661847 to your computer and use it in GitHub Desktop.
Save kshenoy/5661847 to your computer and use it in GitHub Desktop.
Function to set the foldtext
function! FoldText()
" Description: Folding configuration
let nucolwidth = &fdc + &number*&numberwidth
let winwidth = winwidth(0) - nucolwidth - 3
let foldlinecount = foldclosedend(v:foldstart) - foldclosed(v:foldstart) + 1
let dashtext = strpart(string(v:folddashes),1,len(string(v:folddashes))-2)
let foldinfo = "+" . dashtext . " Fold: " . string(v:foldlevel) . ", " . string(foldlinecount) . " lines "
let firstline = strpart(getline(v:foldstart), 0 , winwidth - len(foldinfo))
let fillcharcount = winwidth - len(firstline) - len(foldinfo)
return firstline . repeat(" ",fillcharcount) . foldinfo
endfunction
set foldtext=FoldText()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment