Created
August 15, 2012 15:20
-
-
Save sjl/3360978 to your computer and use it in GitHub Desktop.
This file contains 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) | |
let nucolwidth = &fdc + &number * &numberwidth | |
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
Great function, thanks for posting! Was the cleanest I saw in a search for the best way to modify the foldtext setting.
I found you can get the displayed length of a line (taking into account tabstop) with strdisplaywidth().
So, the following section could be removed:
And then line 13 would become:
Anyways, I know this is a very old gist, but I just thought I'd post here and pass the info back as a thank you for posting your code ;)