# HG changeset patch # User Steve Losh # Date 1276194312 14400 # Node ID 52be542a43c139c48d70da1776be7e3fe512c4c4 # Parent 24c78d478e3664db84a4091945932c6b10834daa vim: add custom foldtext diff -r 24c78d478e36 -r 52be542a43c1 vim/.vimrc --- a/vim/.vimrc Wed Jun 09 17:00:10 2010 -0400 +++ b/vim/.vimrc Thu Jun 10 14:25:12 2010 -0400 @@ -91,6 +91,25 @@ set foldlevelstart=1 nnoremap za vnoremap za +au BufNewFile,BufRead *.html map ft Vatzf + +setlocal foldtext=MyFoldText() +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) - 1 + return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' +endfunction + " Fuck you, help key. imap