Skip to content

Commit

Permalink
Update by original
Browse files Browse the repository at this point in the history
  • Loading branch information
h-east committed Dec 18, 2024
1 parent 86042fa commit 8868f07
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
4 changes: 2 additions & 2 deletions doc/fold.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*fold.txt* For Vim バージョン 9.1. Last change: 2024 Dec 16
*fold.txt* For Vim バージョン 9.1. Last change: 2024 Dec 17


VIMリファレンスマニュアル by Bram Moolenaar
Expand Down Expand Up @@ -474,7 +474,7 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折

折り畳みに対してコマンドを実行する ~

:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
閉じた折り畳みの中以外の全ての行に対して{cmd}を実行する。
[range]が与えられた時は、その範囲だけが対象となる。
コマンドが各行に対して実行される時にはカーソルはその対象となる
Expand Down
36 changes: 20 additions & 16 deletions en/fold.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 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
will also start (end) when the fold level is higher (lower) than the fold
Expand All @@ -122,7 +123,7 @@ For debugging the 'debug' option can be set to "msg", the error messages will
be visible then.

If the 'foldexpr' expression starts with s: or |<SID>|, then it is replaced
with the script ID (|local-function|). Examples: >
with the script ID (|local-function|). Examples: >
set foldexpr=s:MyFoldExpr()
set foldexpr=<SID>SomeFoldExpr()
<
Expand All @@ -146,21 +147,23 @@ end in that line.
It may happen that folds are not updated properly. You can use |zx| or |zX|
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,
especially when the fold level of all lines have to be initially computed.
Afterwards, after each change, Vim restricts the computation of foldlevels
to those lines whose fold level was affected by it (and reuses the known
foldlevels of all the others).

The fold expression should therefore strive to minimize the number of dependent
lines needed for the computation of a given line: For example, try to avoid the
"=", "a" and "s" return values, because these will require the evaluation of the
fold levels on previous lines until an independent fold level is found.
The fold expression should therefore strive to minimize the number of
dependent lines needed for the computation of a given line: For example, try
to avoid the "=", "a" and "s" return values, because these will require the
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
in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick|:
If this proves difficult, the next best thing could be to cache all fold
levels in a buffer-local variable (b:foldlevels) that is only updated on
|b:changedtick|:
>vim
vim9script
def MyFoldFunc(): number
Expand All @@ -174,8 +177,9 @@ in a buffer-local variable (b:foldlevels) that is only updated on |b:changedtick
enddef
set foldexpr=s:MyFoldFunc()
<
In above example further speedup was gained by using a precompiled Vim9script
function without arguments (that must still use v:lnum). See |expr-option-function|.
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|.

SYNTAX *fold-syntax*

Expand Down Expand Up @@ -412,8 +416,8 @@ zX Undo manually opened and closed folds: re-apply 'foldlevel'.
Also forces recomputing folds, like |zx|.

*zm*
zm Fold more: Subtract |v:count1| from 'foldlevel'. If 'foldlevel' was
already zero nothing happens.
zm Fold more: Subtract |v:count1| from 'foldlevel'. If
'foldlevel' was already zero nothing happens.
'foldenable' will be set.

*zM*
Expand Down Expand Up @@ -477,7 +481,7 @@ zk Move upwards to the end of the previous fold. A closed fold

EXECUTING COMMANDS ON FOLDS ~

:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
:[range]foldd[oopen] {cmd} *:foldd* *:folddo* *:folddoopen*
Execute {cmd} on all lines that are not in a closed fold.
When [range] is given, only these lines are used.
Each time {cmd} is executed the cursor is positioned on the
Expand Down Expand Up @@ -567,7 +571,7 @@ When there is room after the text, it is filled with the character specified
by 'fillchars'.

If the 'foldtext' expression starts with s: or |<SID>|, then it is replaced
with the script ID (|local-function|). Examples: >
with the script ID (|local-function|). Examples: >
set foldtext=s:MyFoldText()
set foldtext=<SID>SomeFoldText()
<
Expand Down

0 comments on commit 8868f07

Please sign in to comment.