Skip to content

Commit a9ed7b1

Browse files
authored
Merge pull request #980 from tsuyoshicho/update/20211129/autocmd
Update autocmd.{txt.jax}
2 parents c646155 + 7d4a433 commit a9ed7b1

File tree

2 files changed

+97
-15
lines changed

2 files changed

+97
-15
lines changed

doc/autocmd.jax

+47-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*autocmd.txt* For Vim バージョン 8.2. Last change: 2021 Jul 27
1+
*autocmd.txt* For Vim バージョン 8.2. Last change: 2021 Nov 20
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -72,10 +72,16 @@
7272
内) にあると {cmd} は Vim9 script として実行される。したがってこの依存は自動コ
7373
マンドが定義された位置に依存し、トリガーされた位置ではない。
7474

75-
Note: '|' が {cmd} の前にある場合、":autocmd" コマンドの後には別のコマンドを続
76-
けることができる。これは動作する: >
75+
{cmd}`:command` のようにブロックにできる。|:command-repl| を参照。例: >
76+
au BufReadPost *.xml {
77+
setlocal matchpairs+=<:>
78+
/<start
79+
}
80+
81+
Note: ":autocmd" コマンドの後には、パターンが期待される位置に '|' が現れる場合
82+
にのみ別のコマンドを続けることができる。これは動作する: >
7783
:augroup mine | au! BufRead | augroup END
78-
しかし、これは定義されたコマンドの一部として "augroup" を見る: >
84+
しかし、これは定義されたコマンドの一部として "augroup" を見做す: >
7985
:augroup mine | au! BufRead * | augroup END
8086
:augroup mine | au BufRead * set tw=70 | augroup END
8187
代わりにグループ名をコマンドの中に置くことができる: >
@@ -348,6 +354,7 @@ Vimは以下のイベントを認識する。イベント名が大文字か小
348354

349355
|WinNew| 新しいウィンドウを作成した後
350356
|TabNew| 新しいタブページを作成した後
357+
|WinClosed| ウィンドウを閉じた後
351358
|TabClosed| タブページを閉じた後
352359
|WinEnter| 別のウィンドウに入った後
353360
|WinLeave| ウィンドウから離れる前
@@ -366,6 +373,8 @@ Vimは以下のイベントを認識する。イベント名が大文字か小
366373
|InsertCharPre| 挿入モードで文字が入力されたとき、その文字が挿入される
367374
368375

376+
|ModeChanged| モード変更後
377+
369378
|TextChanged| ノーマルモードでテキストが変更された後
370379
|TextChangedI| ポップアップメニューが表示されていないときに、挿入モー
371380
ドでテキストが変更された後
@@ -701,7 +710,7 @@ EncodingChanged オプション 'encoding' が変更されたとき。例え
701710
フォント等の設定に便利である。
702711
*FileAppendCmd*
703712
FileAppendCmd ファイルに追加する前。ファイルへの追加の役目を
704-
負う。 |Cmd-event|
713+
負う。|Cmd-event|
705714
*FileAppendPost*
706715
FileAppendPost ファイルに追加した後。
707716
*FileAppendPre*
@@ -903,7 +912,25 @@ MenuPopup (マウス右ボタンで)ポップアップメニューを表示す
903912
i 挿入
904913
c コマンドライン
905914
tl 端末
906-
*OptionSet*
915+
*ModeChanged*
916+
ModeChanged モード変更後。パターンは `'old_mode:new_mode'`
917+
に対してマッチングされ、例えば、|CmdlineEnter|
918+
をシミュレートするには、`*:c*` に対してマッチ
919+
させる。
920+
|v:event| には以下の値が設定される:
921+
old_mode 変更前のモード。
922+
new_mode 非0の引数で呼び出された
923+
|mode()| によっても返される新
924+
しいモード。
925+
ModeChanged が発行された時、old_mode は最後に
926+
発行された時の new_mode の値を持つ。
927+
各マイナーモードが変更されるたびに発行される。
928+
使い方の例としてビジュアルモードに入ったら相対
929+
行番号を使うもの: >
930+
:au ModeChanged [vV\x16]*:* let &l:rnu = mode() =~# '^[vV\x16]'
931+
:au ModeChanged *:[vV\x16]* let &l:rnu = mode() =~# '^[vV\x16]'
932+
:au WinEnter,WinLeave * let &l:rnu = mode() =~# '^[vV\x16]'
933+
< *OptionSet*
907934
OptionSet オプションが設定された後。パターンは長い(短縮
908935
しない)オプション名に対してマッチする。
909936
|<amatch>| は対象のオプション名が設定される。
@@ -1158,7 +1185,8 @@ TextYankPost カレントバッファでテキストがヤンクもしくは
11581185
テキストのリスト。以下と同様: >
11591186
getreg(r, 1, 1)
11601187
< regname レジスタの名前、もしくは無名レ
1161-
ジスタの場合は空文字列。
1188+
ジスタの場合は空文字列、
1189+
|registers| を参照。
11621190
regtype レジスタの種類、|getregtype()|
11631191
を参照。
11641192
visual オペレーションが |Visual| エリ
@@ -1235,6 +1263,11 @@ VimResume Vimがサスペンドと |VimSuspend| がトリガーした
12351263
VimSuspend Vimのインスタンスがサスペンドしたとき。Vim内で
12361264
CTRL-Z がタイプされた時だけであり、SIGSTOP か
12371265
SIGTSTP シグナルがVimに送られた時ではない。
1266+
*WinClosed*
1267+
WinClosed ウィンドウが閉じた後。パターンは |window-ID|
1268+
に対して照合される。<amatch><afile> は共に
1269+
|window-ID| を設定する。再帰的に発生しない(こ
1270+
のイベントで自分自身を発行しない)。
12381271
*WinEnter*
12391272
WinEnter 別のウィンドウに入った後。Vimの開始直後、1個目
12401273
のウィンドウに入ったときは発生しない。ウィンド
@@ -1458,6 +1491,13 @@ Note: パスの途中だけにマッチさせ、ルートディレクトリに
14581491
これで自動コマンドを (例えばファイル .vimrc を再び読み込んだ後) 2回定義するこ
14591492
とが防げる。
14601493

1494+
*FileExplorer*
1495+
Vim によって認識されるグループが1つある: FileExplorer。このグループが存在する
1496+
なら Vim はディレクトリが編集可能であると想定しディレクトリ内のファイルを列挙
1497+
するプラグインが呼ばれる。これは |netrw| プラグインによって使われる。これによ
1498+
り次のことが可能になる: >
1499+
browse edit
1500+
14611501
==============================================================================
14621502
9. 自動コマンドの実行 *autocmd-execute*
14631503

en/autocmd.txt

+50-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*autocmd.txt* For Vim version 8.2. Last change: 2021 Jul 27
1+
*autocmd.txt* For Vim version 8.2. Last change: 2021 Nov 20
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -76,8 +76,14 @@ and in a `:def` function) then {cmd} will be executed as in Vim9
7676
script. Thus this depends on where the autocmd is defined, not where it is
7777
triggered.
7878

79+
{cmd} can be a block, like with `:command`, see |:command-repl|. Example: >
80+
au BufReadPost *.xml {
81+
setlocal matchpairs+=<:>
82+
/<start
83+
}
84+
7985
Note: The ":autocmd" command can only be followed by another command when the
80-
'|' appears before {cmd}. This works: >
86+
'|' appears where the pattern is expected. This works: >
8187
:augroup mine | au! BufRead | augroup END
8288
But this sees "augroup" as part of the defined command: >
8389
:augroup mine | au! BufRead * | augroup END
@@ -342,6 +348,7 @@ Name triggered by ~
342348

343349
|WinNew| after creating a new window
344350
|TabNew| after creating a new tab page
351+
|WinClosed| after closing a window
345352
|TabClosed| after closing a tab page
346353
|WinEnter| after entering another window
347354
|WinLeave| before leaving a window
@@ -360,6 +367,8 @@ Name triggered by ~
360367
|InsertCharPre| when a character was typed in Insert mode, before
361368
inserting it
362369

370+
|ModeChanged| after changing the mode
371+
363372
|TextChanged| after a change was made to the text in Normal mode
364373
|TextChangedI| after a change was made to the text in Insert mode
365374
when popup menu is not visible
@@ -700,7 +709,7 @@ EncodingChanged Fires off after the 'encoding' option has been
700709
*FileAppendCmd*
701710
FileAppendCmd Before appending to a file. Should do the
702711
appending to the file. Use the '[ and ']
703-
marks for the range of lines.|Cmd-event|
712+
marks for the range of lines. |Cmd-event|
704713
*FileAppendPost*
705714
FileAppendPost After appending to a file.
706715
*FileAppendPre*
@@ -828,7 +837,7 @@ FilterReadPre Before reading a file from a filter command.
828837
*FilterWritePost*
829838
FilterWritePost After writing a file for a filter command or
830839
making a diff with an external diff (see
831-
DiffUpdated for internal diff).
840+
|DiffUpdated| for internal diff).
832841
Vim checks the pattern against the name of
833842
the current buffer as with FilterWritePre.
834843
Not triggered when 'shelltemp' is off.
@@ -919,7 +928,27 @@ MenuPopup Just before showing the popup menu (under the
919928
i Insert
920929
c Command line
921930
tl Terminal
922-
*OptionSet*
931+
*ModeChanged*
932+
ModeChanged After changing the mode. The pattern is
933+
matched against `'old_mode:new_mode'`, for
934+
example match against `*:c*` to simulate
935+
|CmdlineEnter|.
936+
The following values of |v:event| are set:
937+
old_mode The mode before it changed.
938+
new_mode The new mode as also returned
939+
by |mode()| called with a
940+
non-zero argument.
941+
When ModeChanged is triggered, old_mode will
942+
have the value of new_mode when the event was
943+
last triggered.
944+
This will be triggered on every minor mode
945+
change.
946+
Usage example to use relative line numbers
947+
when entering Visual mode: >
948+
:au ModeChanged [vV\x16]*:* let &l:rnu = mode() =~# '^[vV\x16]'
949+
:au ModeChanged *:[vV\x16]* let &l:rnu = mode() =~# '^[vV\x16]'
950+
:au WinEnter,WinLeave * let &l:rnu = mode() =~# '^[vV\x16]'
951+
< *OptionSet*
923952
OptionSet After setting an option. The pattern is
924953
matched against the long option name.
925954
|<amatch>| indicates what option has been set.
@@ -1172,9 +1201,9 @@ TextYankPost After text has been yanked or deleted in the
11721201
register, as a list of lines,
11731202
like with: >
11741203
getreg(r, 1, 1)
1175-
< regname Name of the |register| or
1176-
empty string for the unnamed
1177-
register.
1204+
< regname Name of the register or empty
1205+
string for the unnamed
1206+
register, see |registers|.
11781207
regtype Type of the register, see
11791208
|getregtype()|.
11801209
visual True if the operation is
@@ -1252,6 +1281,12 @@ VimResume When the Vim instance is resumed after being
12521281
VimSuspend When the Vim instance is suspended. Only when
12531282
CTRL-Z was typed inside Vim, not when the
12541283
SIGSTOP or SIGTSTP signal was sent to Vim.
1284+
*WinClosed*
1285+
WinClosed After closing a window. The pattern is
1286+
matched against the |window-ID|. Both
1287+
<amatch> and <afile> are set to the
1288+
|window-ID|. Non-recursive (event cannot
1289+
trigger itself).
12551290
*WinEnter*
12561291
WinEnter After entering another window. Not done for
12571292
the first window, when Vim has just started.
@@ -1479,6 +1514,13 @@ Example: >
14791514
This prevents having the autocommands defined twice (e.g., after sourcing the
14801515
.vimrc file again).
14811516

1517+
*FileExplorer*
1518+
There is one group that is recognized by Vim: FileExplorer. If this group
1519+
exists Vim assumes that editing a directory is possible and will trigger a
1520+
plugin that lists the files in that directory. This is used by the |netrw|
1521+
plugin. This allows you to do: >
1522+
browse edit
1523+
14821524
==============================================================================
14831525
9. Executing autocommands *autocmd-execute*
14841526

0 commit comments

Comments
 (0)