diff options
author | jluehrs2 <jluehrs2@uiuc.edu> | 2008-04-21 03:46:03 -0500 |
---|---|---|
committer | jluehrs2 <jluehrs2@uiuc.edu> | 2008-04-21 03:46:03 -0500 |
commit | 5da66ba2eb49d016986c975eac8c340b7c00e9c3 (patch) | |
tree | a08d72abb89f3b80e23cfa6b7f90432944b31600 | |
parent | 6a17cc237e4911775162a05b6cb3b89e4171a15b (diff) | |
download | vim-foldtext-5da66ba2eb49d016986c975eac8c340b7c00e9c3.tar.gz vim-foldtext-5da66ba2eb49d016986c975eac8c340b7c00e9c3.zip |
make comment stripping more intelligent
-rw-r--r-- | vimrc | 18 |
1 files changed, 14 insertions, 4 deletions
@@ -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 |