From a81b05fc4d2e1d49d6557df854c5b688125d14dc Mon Sep 17 00:00:00 2001 From: jluehrs2 Date: Sun, 20 Apr 2008 22:25:23 -0500 Subject: add a special foldtext function to strip out single line comments from c++ files --- vimrc | 17 +++++++++++++++-- 1 file 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 " }}} " }}} -- cgit v1.2.3-54-g00ecf