mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
runtime(doc): Fix style in fold.txt
closes: #16236 Co-authored-by: zeertzjq <zeertzjq@outlook.com> Signed-off-by: h-east <h.east.727@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
38281e1b96
commit
a977883ef3
@ -1,4 +1,4 @@
|
|||||||
*fold.txt* For Vim version 9.1. Last change: 2024 Dec 16
|
*fold.txt* For Vim version 9.1. Last change: 2024 Dec 17
|
||||||
|
|
||||||
|
|
||||||
VIM REFERENCE MANUAL by Bram Moolenaar
|
VIM REFERENCE MANUAL by Bram Moolenaar
|
||||||
@ -106,7 +106,8 @@ The result of foldexpr then determines the fold level as follows:
|
|||||||
"<1", "<2", .. a fold with this level ends at this line
|
"<1", "<2", .. a fold with this level ends at this line
|
||||||
">1", ">2", .. a fold with this level starts at this line
|
">1", ">2", .. a fold with this level starts at this line
|
||||||
|
|
||||||
The result values "=", "s" and "a" are more expensive, please see |fold-expr-slow|.
|
The result values "=", "s" and "a" are more expensive, please see
|
||||||
|
|fold-expr-slow|.
|
||||||
|
|
||||||
It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
|
It is not required to mark the start (end) of a fold with ">1" ("<1"), a fold
|
||||||
will also start (end) when the fold level is higher (lower) than the fold
|
will also start (end) when the fold level is higher (lower) than the fold
|
||||||
@ -146,7 +147,7 @@ end in that line.
|
|||||||
It may happen that folds are not updated properly. You can use |zx| or |zX|
|
It may happen that folds are not updated properly. You can use |zx| or |zX|
|
||||||
to force updating folds.
|
to force updating folds.
|
||||||
|
|
||||||
Minimizing Computational Cost *fold-expr-slow*
|
MINIMIZING COMPUTATIONAL COST *fold-expr-slow*
|
||||||
|
|
||||||
Due to its computational cost, this fold method can make Vim unresponsive,
|
Due to its computational cost, this fold method can make Vim unresponsive,
|
||||||
especially when the fold level of all lines have to be initially computed.
|
especially when the fold level of all lines have to be initially computed.
|
||||||
@ -154,13 +155,15 @@ Afterwards, after each change, Vim restricts the computation of foldlevels
|
|||||||
to those lines whose fold level was affected by it (and reuses the known
|
to those lines whose fold level was affected by it (and reuses the known
|
||||||
foldlevels of all the others).
|
foldlevels of all the others).
|
||||||
|
|
||||||
The fold expression should therefore strive to minimize the number of dependent
|
The fold expression should therefore strive to minimize the number of
|
||||||
lines needed for the computation of a given line: For example, try to avoid the
|
dependent lines needed for the computation of a given line: For example, try
|
||||||
"=", "a" and "s" return values, because these will require the evaluation of the
|
to avoid the "=", "a" and "s" return values, because these will require the
|
||||||
fold levels on previous lines until an independent fold level is found.
|
evaluation of the fold levels on previous lines until an independent fold
|
||||||
|
level is found.
|
||||||
|
|
||||||
If this proves difficult, the next best thing could be to cache all fold levels
|
If this proves difficult, the next best thing could be to cache all fold
|
||||||
in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick|:
|
levels in a buffer-local variable (b:foldlevels) that is only updated on
|
||||||
|
|b:changedtick|:
|
||||||
>vim
|
>vim
|
||||||
vim9script
|
vim9script
|
||||||
def MyFoldFunc(): number
|
def MyFoldFunc(): number
|
||||||
@ -174,8 +177,9 @@ in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick
|
|||||||
enddef
|
enddef
|
||||||
set foldexpr=s:MyFoldFunc()
|
set foldexpr=s:MyFoldFunc()
|
||||||
<
|
<
|
||||||
In above example further speedup was gained by using a precompiled Vim9script
|
In above example further speedup was gained by using a precompiled Vim9 script
|
||||||
function without arguments (that must still use v:lnum). See |expr-option-function|.
|
function without arguments (that must still use v:lnum). See
|
||||||
|
|expr-option-function|.
|
||||||
|
|
||||||
SYNTAX *fold-syntax*
|
SYNTAX *fold-syntax*
|
||||||
|
|
||||||
@ -412,8 +416,8 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
|
|||||||
Also forces recomputing folds, like |zx|.
|
Also forces recomputing folds, like |zx|.
|
||||||
|
|
||||||
*zm*
|
*zm*
|
||||||
zm Fold more: Subtract |v:count1| from 'foldlevel'. If 'foldlevel' was
|
zm Fold more: Subtract |v:count1| from 'foldlevel'. If
|
||||||
already zero nothing happens.
|
'foldlevel' was already zero nothing happens.
|
||||||
'foldenable' will be set.
|
'foldenable' will be set.
|
||||||
|
|
||||||
*zM*
|
*zM*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user