summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjluehrs2 <jluehrs2@uiuc.edu>2008-04-21 03:46:03 -0500
committerjluehrs2 <jluehrs2@uiuc.edu>2008-04-21 03:46:03 -0500
commit5da66ba2eb49d016986c975eac8c340b7c00e9c3 (patch)
treea08d72abb89f3b80e23cfa6b7f90432944b31600
parent6a17cc237e4911775162a05b6cb3b89e4171a15b (diff)
downloadvim-foldtext-5da66ba2eb49d016986c975eac8c340b7c00e9c3.tar.gz
vim-foldtext-5da66ba2eb49d016986c975eac8c340b7c00e9c3.zip
make comment stripping more intelligent
-rw-r--r--vimrc18
1 files changed, 14 insertions, 4 deletions
diff --git a/vimrc b/vimrc
index 66adf1b..826c6fc 100644
--- a/vimrc
+++ b/vimrc
@@ -157,10 +157,20 @@ function Base_foldtext(...)
" remove comments that we know about
let comment = split(&commentstring, '%s')
if comment[0] != ''
- let line = substitute(line, '\V' . comment[0], ' ', '')
- endif
- if comment[1] != ''
- let line = substitute(line, '\V' . comment[1], ' ', '')
+ let comment_begin = comment[0]
+ let comment_end = ''
+ if len(comment) > 1
+ let comment_end = comment[1]
+ end
+ let pattern = '\V' . comment_begin . '\s\*' . comment_end . '\s\*\$'
+ if line =~ pattern
+ let line = substitute(line, pattern, ' ', '')
+ else
+ let line = substitute(line, '.*\V' . comment_begin, ' ', '')
+ if comment_end != ''
+ let line = substitute(line, '\V' . comment_end, ' ', '')
+ endif
+ endif
endif
" remove any remaining leading or trailing whitespace