1- *fold.txt* For Vim version 9.1. Last change: 2024 Dec 16
1+ *fold.txt* For Vim version 9.1. Last change: 2024 Dec 17
22
33
44 VIM REFERENCE MANUAL by Bram Moolenaar
@@ -106,7 +106,8 @@ The result of foldexpr then determines the fold level as follows:
106106 "<1", "<2", .. a fold with this level ends at this line
107107 ">1", ">2", .. a fold with this level starts at this line
108108
109- The result values "=", "s" and "a" are more expensive, please see | fold-expr-slow | .
109+ The result values "=", "s" and "a" are more expensive, please see
110+ | fold-expr-slow | .
110111
111112It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
112113will also start (end) when the fold level is higher (lower) than the fold
@@ -122,7 +123,7 @@ For debugging the 'debug' option can be set to "msg", the error messages will
122123be visible then.
123124
124125If the 'foldexpr' expression starts with s: or | <SID> | , then it is replaced
125- with the script ID (| local-function | ). Examples: >
126+ with the script ID (| local-function | ). Examples: >
126127 set foldexpr=s:MyFoldExpr()
127128 set foldexpr=<SID>SomeFoldExpr()
128129<
@@ -146,21 +147,23 @@ end in that line.
146147It may happen that folds are not updated properly. You can use | zx | or | zX |
147148to force updating folds.
148149
149- Minimizing Computational Cost *fold-expr-slow*
150+ MINIMIZING COMPUTATIONAL COST *fold-expr-slow*
150151
151152Due to its computational cost, this fold method can make Vim unresponsive,
152153especially when the fold level of all lines have to be initially computed.
153154Afterwards, after each change, Vim restricts the computation of foldlevels
154155to those lines whose fold level was affected by it (and reuses the known
155156foldlevels of all the others).
156157
157- The fold expression should therefore strive to minimize the number of dependent
158- lines needed for the computation of a given line: For example, try to avoid the
159- "=", "a" and "s" return values, because these will require the evaluation of the
160- fold levels on previous lines until an independent fold level is found.
158+ The fold expression should therefore strive to minimize the number of
159+ dependent lines needed for the computation of a given line: For example, try
160+ to avoid the "=", "a" and "s" return values, because these will require the
161+ evaluation of the fold levels on previous lines until an independent fold
162+ level is found.
161163
162- If this proves difficult, the next best thing could be to cache all fold levels
163- in a buffer-local variable (b:foldlevels) that is only updated on | b:changedtick | :
164+ If this proves difficult, the next best thing could be to cache all fold
165+ levels in a buffer-local variable (b:foldlevels) that is only updated on
166+ | b:changedtick | :
164167>vim
165168 vim9script
166169 def MyFoldFunc(): number
@@ -174,8 +177,9 @@ in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick
174177 enddef
175178 set foldexpr=s:MyFoldFunc()
176179<
177- In above example further speedup was gained by using a precompiled Vim9script
178- function without arguments (that must still use v:lnum). See | expr-option-function | .
180+ In above example further speedup was gained by using a precompiled Vim9 script
181+ function without arguments (that must still use v:lnum). See
182+ | expr-option-function | .
179183
180184SYNTAX *fold-syntax*
181185
@@ -412,8 +416,8 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
412416 Also forces recomputing folds, like | zx | .
413417
414418 *zm*
415- zm Fold more: Subtract | v:count1 | from 'foldlevel' . If 'foldlevel' was
416- already zero nothing happens.
419+ zm Fold more: Subtract | v:count1 | from 'foldlevel' . If
420+ 'foldlevel' was already zero nothing happens.
417421 'foldenable' will be set.
418422
419423 *zM*
@@ -477,7 +481,7 @@ zk Move upwards to the end of the previous fold. A closed fold
477481
478482EXECUTING COMMANDS ON FOLDS ~
479483
480- :[range] foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
484+ :[range] foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
481485 Execute {cmd} on all lines that are not in a closed fold.
482486 When [range] is given, only these lines are used.
483487 Each time {cmd} is executed the cursor is positioned on the
@@ -567,7 +571,7 @@ When there is room after the text, it is filled with the character specified
567571by 'fillchars' .
568572
569573If the 'foldtext' expression starts with s: or | <SID> | , then it is replaced
570- with the script ID (| local-function | ). Examples: >
574+ with the script ID (| local-function | ). Examples: >
571575 set foldtext=s:MyFoldText()
572576 set foldtext=<SID>SomeFoldText()
573577<
0 commit comments