diff options
author | Bram Moolenaar <Bram@vim.org> | 2022-10-01 15:32:46 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-10-01 15:32:46 +0100 |
commit | 87b4e5c5db9d1cfd6f2e79656e1a6cff3c69d15f (patch) | |
tree | a437917654ad79edd9764b4f67af33ce01228d6a /runtime/doc/fold.txt | |
parent | 145d1fd91041bd2a22a11eef0357702e420796e2 (diff) |
patch 9.0.0632: calling a function from an "expr" option has overheadv9.0.0632
Problem: Calling a function from an "expr" option has too much overhead.
Solution: Add call_simple_func() and use it for 'foldexpr'
Diffstat (limited to 'runtime/doc/fold.txt')
-rw-r--r-- | runtime/doc/fold.txt | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt index 93efcbb664..f11ca0812d 100644 --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -74,8 +74,6 @@ method. The value of the 'foldexpr' option is evaluated to get the foldlevel of a line. Examples: This will create a fold for all consecutive lines that start with a tab: > :set foldexpr=getline(v:lnum)[0]==\"\\t\" -This will call a function to compute the fold level: > - :set foldexpr=MyFoldLevel(v:lnum) This will make a fold out of paragraphs separated by blank lines: > :set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1 This does the same: > @@ -84,6 +82,10 @@ This does the same: > Note that backslashes must be used to escape characters that ":set" handles differently (space, backslash, double quote, etc., see |option-backslash|). +The most efficient is to call a compiled function without arguments: > + :set foldexpr=MyFoldLevel() +The function must use v:lnum. See |expr-option-function|. + These are the conditions with which the expression is evaluated: - The current buffer and window are set for the line. - The variable "v:lnum" is set to the line number. |