summaryrefslogtreecommitdiffstats
path: root/runtime/doc/fold.txt
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-11-24 19:18:36 +0100
committerBram Moolenaar <Bram@vim.org>2015-11-24 19:18:36 +0100
commitd042dc825c9b97dacd84d4728f88300da4d5b6b9 (patch)
tree035c5232653999ca8f7a84ba67e57eb6dcac8f42 /runtime/doc/fold.txt
parent0f6562e9036f889185dff49a75c7fc5ffb28b307 (diff)
Update runtime files.
Diffstat (limited to 'runtime/doc/fold.txt')
-rw-r--r--runtime/doc/fold.txt18
1 files changed, 15 insertions, 3 deletions
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt
index 20017d3538..e2ea1ab66d 100644
--- a/runtime/doc/fold.txt
+++ b/runtime/doc/fold.txt
@@ -1,4 +1,4 @@
-*fold.txt* For Vim version 7.4. Last change: 2013 Dec 04
+*fold.txt* For Vim version 7.4. Last change: 2015 Nov 24
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -97,9 +97,9 @@ These are the conditions with which the expression is evaluated:
lowest.
"=" use fold level from the previous line
"a1", "a2", .. add one, two, .. to the fold level of the previous
- line
+ line, use the result for the current line
"s1", "s2", .. subtract one, two, .. from the fold level of the
- previous line
+ previous line, use the result for the next line
"<1", "<2", .. a fold with this level ends at this line
">1", ">2", .. a fold with this level starts at this line
@@ -122,6 +122,18 @@ method can be very slow!
Try to avoid the "=", "a" and "s" return values, since Vim often has to search
backwards for a line for which the fold level is defined. This can be slow.
+An example of using "a1" and "s1": For a multi-line C comment, a line
+containing "/*" would return "a1" to start a fold, and a line containing "*/"
+would return "s1" to end the fold after that line: >
+ if match(thisline, '/\*') >= 0
+ return 'a1'
+ elseif match(thisline, '\*/') >= 0
+ return 's1'
+ else
+ return '='
+ endif
+However, this won't work for single line comments, strings, etc.
+
|foldlevel()| can be useful to compute a fold level relative to a previous
fold level. But note that foldlevel() may return -1 if the level is not known
yet. And it returns the level at the start of the line, while a fold might