summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-20 22:25:23 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-20 22:25:23 -0500
commita81b05fc4d2e1d49d6557df854c5b688125d14dc (patch)
treee3d14f785524e63ab9fbba56ff626c6260de42fc
parent51e9f84eaf215c1608d3d535e85517e77ea35d20 (diff)
downloadvim-foldtext-a81b05fc4d2e1d49d6557df854c5b688125d14dc.tar.gz
vim-foldtext-a81b05fc4d2e1d49d6557df854c5b688125d14dc.zip
add a special foldtext function to strip out single line comments from c++ files
-rw-r--r--vimrc17
1 files changed, 15 insertions, 2 deletions
diff --git a/vimrc b/vimrc
index 34808d0..92297db 100644
--- a/vimrc
+++ b/vimrc
@@ -190,6 +190,7 @@ autocmd FileType tex setlocal makeprg=~/bin/latexpdf\ --show\ %
" }}}
" Set up custom folding {{{
autocmd FileType tex set foldtext=Latex_foldtext()
+autocmd FileType cpp set foldtext=Cpp_foldtext()
" }}}
"}}}
@@ -333,8 +334,20 @@ function Latex_foldtext()
return Base_foldtext(s:latex_types[matches[1]] . ": " . matches[2])
endif
- " otherwise, just strip latex comments from the line
- return Base_foldtext(substitute(line, '\s\?%\s\?', ' ', ''))
+ return Base_foldtext()
+endfunction
+" }}}
+" C++ {{{
+function Cpp_foldtext()
+ let line = getline(v:foldstart)
+
+ let block_open = stridx(line, '/*')
+ let line_open = stridx(line, '//')
+ if block_open == -1 || line_open < block_open
+ return Base_foldtext(substitute(line, '//', ' ', ''))
+ endif
+
+ return Base_foldtext(line)
endfunction
" }}}
" }}}