diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/doc/fold.txt | 6 | ||||
-rw-r--r-- | runtime/doc/options.txt | 8 |
2 files changed, 12 insertions, 2 deletions
diff --git a/runtime/doc/fold.txt b/runtime/doc/fold.txt index 8f7393f5e3..b844e0ed85 100644 --- a/runtime/doc/fold.txt +++ b/runtime/doc/fold.txt @@ -69,8 +69,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: > @@ -79,6 +77,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 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. diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 875767283a..a48d020a34 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -400,6 +400,14 @@ Set using a variable with lambda expression: > let L = {a, b, c -> MyTagFunc(a, b , c)} let &tagfunc = L +Calling a function in an expr option *expr-option-function* + +The value of a few options, such as 'foldexpr', is an expression that is +evaluated to get a value. The evaluation can have quite a bit of overhead. +One way to minimize the overhead, and also to keep the option value very +simple, is to define a function and set the option to call it without +arguments. + Setting the filetype |