-
-
Save miketierney/3383433 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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