summaryrefslogtreecommitdiff
path: root/runtime/doc/fold.txt
diff options
context:
space:
mode:
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 20017d353..e2ea1ab66 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