Skip to content

Commit 7ddd4c5

Browse files
committed
fold.txt: Update Vim 9.0.0701
1 parent 2f1c4e2 commit 7ddd4c5

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

en/fold.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*fold.txt* For Vim version 9.0. Last change: 2022 Jan 22
1+
*fold.txt* For Vim version 9.0. Last change: 2022 Oct 01
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -74,8 +74,6 @@ method. The value of the 'foldexpr' option is evaluated to get the foldlevel
7474
of a line. Examples:
7575
This will create a fold for all consecutive lines that start with a tab: >
7676
:set foldexpr=getline(v:lnum)[0]==\"\\t\"
77-
This will call a function to compute the fold level: >
78-
:set foldexpr=MyFoldLevel(v:lnum)
7977
This will make a fold out of paragraphs separated by blank lines: >
8078
:set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
8179
This does the same: >
@@ -84,6 +82,10 @@ This does the same: >
8482
Note that backslashes must be used to escape characters that ":set" handles
8583
differently (space, backslash, double quote, etc., see |option-backslash|).
8684

85+
The most efficient is to call a compiled function without arguments: >
86+
:set foldexpr=MyFoldLevel()
87+
The function must use v:lnum. See |expr-option-function|.
88+
8789
These are the conditions with which the expression is evaluated:
8890
- The current buffer and window are set for the line.
8991
- The variable "v:lnum" is set to the line number.
@@ -501,7 +503,7 @@ is evaluated to obtain the text displayed for a closed fold. Example: >
501503
502504
This shows the first line of the fold, with "/*", "*/" and "{{{" removed.
503505
Note the use of backslashes to avoid some characters to be interpreted by the
504-
":set" command. It's simpler to define a function and call that: >
506+
":set" command. It is much simpler to define a function and call it: >
505507
506508
:set foldtext=MyFoldText()
507509
:function MyFoldText()
@@ -510,6 +512,9 @@ Note the use of backslashes to avoid some characters to be interpreted by the
510512
: return v:folddashes .. sub
511513
:endfunction
512514
515+
The advantage of using a function call without arguments is that it is faster,
516+
see |expr-option-function|.
517+
513518
Evaluating 'foldtext' is done in the |sandbox|. The current window is set to
514519
the window that displays the line. The context is set to the script where the
515520
option was last set.

0 commit comments

Comments
 (0)