Skip to content

Commit 4809ef5

Browse files
authored
Merge pull request #1154 from tsuyoshicho/update/20221009/fold
Update fold.{txt,jax}
2 parents 2aab236 + 28e3b16 commit 4809ef5

File tree

2 files changed

+28
-18
lines changed

2 files changed

+28
-18
lines changed

doc/fold.jax

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*fold.txt* For Vim バージョン 9.0. Last change: 2022 Jan 22
1+
*fold.txt* For Vim バージョン 9.0. Last change: 2022 Oct 01
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -34,7 +34,7 @@
3434
marker テキスト中の印で折り畳みを定義する
3535

3636

37-
手動(MANUAL) *fold-manual*
37+
☆手動 *fold-manual*
3838

3939
折り畳み領域を定義するためにコマンドを手動で利用する。これはテキスト中の折り畳
4040
みを行う箇所をスクリプトにより解析するのに使うこともできる。
@@ -46,7 +46,7 @@
4646
マンドを使用する。後に復元するには|:loadview|を使用する。
4747

4848

49-
インデント(INDENT) *fold-indent*
49+
インデント *fold-indent*
5050

5151
折り畳みは各行のインデントにより自動的に定義される。
5252

@@ -65,20 +65,22 @@
6565
で、ある行のインデントを取得するのに、関数|indent()|を使うことができる。
6666

6767

68-
式(EXPR) *fold-expr*
68+
☆式 *fold-expr*
6969

7070
折り畳みは "indent" 方式のように、折り畳みレベルによって自動的に定義される。
7171
'foldexpr' オプションの値は、各行についてこの折り畳みレベルを計算するためにス
7272
クリプトとして実行される。例:
7373
タブで始まる一連の行範囲を1つの折り畳みにまとめる: >
7474
:set foldexpr=getline(v:lnum)[0]==\"\\t\"
75-
折り畳みレベルを計算するのに Vim script の関数を呼び出す: >
76-
:set foldexpr=MyFoldLevel(v:lnum)
7775
空行で仕切られた「段落」を折り畳みとする: >
7876
:set foldexpr=getline(v:lnum)=~'^\\s*$'&&getline(v:lnum+1)=~'\\S'?'<1':1
7977
同じ事(「段落」を折り畳みに)をする別の表現: >
8078
:set foldexpr=getline(v:lnum-1)=~'^\\s*$'&&getline(v:lnum)=~'\\S'?'>1':1
8179
80+
最も効果的なのはコンパイル済み関数を引数なしで呼ぶ: >
81+
:set foldexpr=MyFoldLevel()
82+
関数は v:lnum を使用しなくてはいけない。|expr-option-function| を参照。
83+
8284
バックスラッシュ(日本では \ 記号)が ":set" の流儀で、通常とは異なるキャラクタ
8385
(空白文字、バックスラッシュ、ダブルクォート、その他、詳細は|option-backslash|
8486
参照)をエスケープしていることに注意。
@@ -143,7 +145,7 @@ NOTE: 各行について式評価が実行されるので、この折り畳み
143145
に更新すること。
144146

145147

146-
構文(SYNTAX) *fold-syntax*
148+
☆構文 *fold-syntax*
147149

148150
折り畳みが "fold" 引数を持つ構文要素によって定義される。 |:syn-fold|
149151

@@ -156,7 +158,7 @@ NOTE: 各行について式評価が実行されるので、この折り畳み
156158
:syn sync fromstart
157159
158160
159-
差分(DIFF) *fold-diff*
161+
☆差分 *fold-diff*
160162

161163
テキストの変更された箇所とその近辺以外が自動的に折り畳みとして定義される。
162164

@@ -173,7 +175,7 @@ NOTE: 各行について式評価が実行されるので、この折り畳み
173175
'scrollbind' が設定されているとき、Vimは他のウィンドウと見た目が同じになるよう
174176
にフォールドを開いた状態に保とうとする。
175177

176-
印(MARKER) *fold-marker*
178+
☆印 *fold-marker*
177179

178180
テキスト中の印により折り畳みの開始と終了地点を指定する。これにより明確に折り畳
179181
みを設定することができる。また誤った行を含むことなく、折り畳みを削除・設定でき
@@ -465,7 +467,7 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折
465467
==============================================================================
466468
3. 折り畳みオプション *fold-options*
467469

468-
*fold-colors*
470+
*fold-colors*
469471

470472
閉じられた折り畳みの色はFoldedグループによって設定される|hl-Folded|。折り畳み
471473
表示カラムの色はFoldColumnグループによって設定される|hl-FoldColumn|
@@ -475,7 +477,7 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折
475477
:highlight FoldColumn guibg=darkgrey guifg=white
476478
477479
478-
折り畳みレベル *fold-foldlevel*
480+
折り畳みレベル *fold-foldlevel*
479481

480482
'foldlevel' は数を設定するオプションである: 大きな数を設定するとより多くの折り
481483
畳みが開かれる。
@@ -490,7 +492,7 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折
490492
ていた折り畳みは開かれない。
491493

492494

493-
折り畳みテキスト *fold-foldtext*
495+
折り畳みテキスト *fold-foldtext*
494496

495497
'foldtext' は式を指定する文字列オプションである。この式は閉じられた折り畳みを
496498
示すテキストを得るために評価実行される。例: >
@@ -499,7 +501,7 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折
499501
500502
これは折り畳みの最初の1行を、"/*" と "*/" を追加し "{{{" を削除して表示する。
501503
多めのバックスラッシュ(\ 記号)はある文字が ":set" コマンドに解釈されてしまうの
502-
を避けるために使用されている。これは以下のように関数を定義するとより簡単になる:
504+
を避けるために使用されている。これは以下のように関数を定義すると最も簡単になる:
503505
>
504506
505507
:set foldtext=MyFoldText()
@@ -509,6 +511,9 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折
509511
: return v:folddashes .. sub
510512
:endfunction
511513
514+
引数なしでの関数呼び出しを使用する利点は高速なことである、
515+
|expr-option-function| を参照のこと。
516+
512517
'foldtext'|sandbox|環境下で実行評価される。現在のウィンドウはそのラインの属
513518
するウィンドウへ設定される。コンテキストはオプションを最後に設定したスクリプト
514519
のものが設定される。
@@ -539,7 +544,7 @@ zk カーソルより上方の折り畳みへ移動する。閉じられた折
539544
ブルクォートを使う場合にはバックスラッシュが必要である。 |option-backslash|
540545

541546

542-
折り畳み表示カラム *fold-foldcolumn*
547+
折り畳み表示カラム *fold-foldcolumn*
543548

544549
'foldcolumn' は、ウィンドウの端に確保される折り畳みを示すカラムの幅を指定する
545550
数。0 ならば、折り畳み表示カラムは確保されない。通常は4から5が一般的。使い物に

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)