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
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -106,7 +106,8 @@ The result of foldexpr then determines the fold level as follows:
106
106
"<1", "<2", .. a fold with this level ends at this line
107
107
">1", ">2", .. a fold with this level starts at this line
108
108
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 | .
110
111
111
112
It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
112
113
will 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
122
123
be visible then.
123
124
124
125
If 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: >
126
127
set foldexpr=s:MyFoldExpr()
127
128
set foldexpr=<SID>SomeFoldExpr()
128
129
<
@@ -146,21 +147,23 @@ end in that line.
146
147
It may happen that folds are not updated properly. You can use | zx | or | zX |
147
148
to force updating folds.
148
149
149
- Minimizing Computational Cost *fold-expr-slow*
150
+ MINIMIZING COMPUTATIONAL COST *fold-expr-slow*
150
151
151
152
Due to its computational cost, this fold method can make Vim unresponsive,
152
153
especially when the fold level of all lines have to be initially computed.
153
154
Afterwards, after each change, Vim restricts the computation of foldlevels
154
155
to those lines whose fold level was affected by it (and reuses the known
155
156
foldlevels of all the others).
156
157
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.
161
163
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 | :
164
167
>vim
165
168
vim9script
166
169
def MyFoldFunc(): number
@@ -174,8 +177,9 @@ in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick
174
177
enddef
175
178
set foldexpr=s:MyFoldFunc()
176
179
<
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 | .
179
183
180
184
SYNTAX *fold-syntax*
181
185
@@ -412,8 +416,8 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
412
416
Also forces recomputing folds, like | zx | .
413
417
414
418
*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.
417
421
'foldenable' will be set.
418
422
419
423
*zM*
@@ -477,7 +481,7 @@ zk Move upwards to the end of the previous fold. A closed fold
477
481
478
482
EXECUTING COMMANDS ON FOLDS ~
479
483
480
- :[range] foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
484
+ :[range] foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
481
485
Execute {cmd} on all lines that are not in a closed fold.
482
486
When [range] is given, only these lines are used.
483
487
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
567
571
by 'fillchars' .
568
572
569
573
If 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: >
571
575
set foldtext=s:MyFoldText()
572
576
set foldtext=<SID>SomeFoldText()
573
577
<
0 commit comments