52be542a43c1

vim: add custom foldtext
[view raw] [browse files]
author Steve Losh <steve@dwaiter.com>
date Thu, 10 Jun 2010 14:25:12 -0400
parents 24c78d478e36
children 181d0ea03b77
branches/tags (none)
files vim/.vimrc

Changes

--- 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 <F1> za
 vnoremap <F1> za
+au BufNewFile,BufRead *.html map <leader>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 <F1> <nop>