Skip to content

Instantly share code, notes, and snippets.

@miketierney
Forked from sjl/foldtext.vim
Created August 17, 2012 23:24
Show Gist options
  • Save miketierney/3383433 to your computer and use it in GitHub Desktop.
Save miketierney/3383433 to your computer and use it in GitHub Desktop.
function! MyFoldText() " {{{
let line = getline(v:foldstart)
" so that it works when relativenumber has been set
if (&relativenumber)
let nucolwidth = &fdc + &relativenumber * &numberwidth
else
let nucolwidth = &fdc + &number * &numberwidth
endif
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount)
return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' '
endfunction " }}}
set foldtext=MyFoldText()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment