Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 43 additions & 37 deletions doc/autocmd.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*autocmd.txt* For Vim バージョン 8.2. Last change: 2022 Apr 08
*autocmd.txt* For Vim バージョン 8.2. Last change: 2022 Apr 17


VIMリファレンスマニュアル by Bram Moolenaar
Expand Down Expand Up @@ -92,6 +92,7 @@ Note: ":autocmd" コマンドの後には、パターンが期待される位置
:augroup mine | exe "au! BufRead *" | augroup END
:augroup mine | exe "au BufRead * set tw=70" | augroup END

< *autocmd-expand*
Note ":autocmd" の引数の中の特別な文字 (例えば "%" や "<cword>" 等) は、自動コ
マンドが定義されたときに展開されるのではなく、イベントの発生が認識され、{cmd}
が実行されるときに展開されることに注意せよ。唯一の例外は、"<sfile>" が自動コマ
Expand Down Expand Up @@ -476,14 +477,16 @@ BufNewFile 存在しないファイルの編集を始めたとき。スケル
BufRead or BufReadPost 新しいバッファの編集を始めたときの、ファイルを
バッファに読み込んだ後で、モードラインを実行す
る前。モードラインを実行した後に何かするには
|BufWinEnter|を参照すること。これは ":r file"
には「動作しない」。ファイルが存在しないときも
使えない。またファイルの復旧に成功したときにも
使われる。
また、":filetype detect" を実行したとき、ある
いは無名バッファを保存してバッファに名前がつい
たとき、filetypedetect グループを対象として発
行される。
|BufWinEnter|を参照すること。
発行される場合:
- 無名バッファを保存してバッファに名前がついた
とき
- ファイルのリカバリーが成功した後
- filetypedetect グループを対象として
":filetype detect" を実行したとき
発行されない場合:
- `:read file` コマンド
- ファイルが存在しないとき
*BufReadCmd*
BufReadCmd 新しいバッファの編集を始める前。ファイルをバッ
ファ内に読み込む役目を負う。 |Cmd-event|
Expand Down Expand Up @@ -710,34 +713,6 @@ CursorMoved ノーマルモードかビジュアルモードでカーソルが
CursorMovedI 挿入モードでカーソルが移動した後。ポップアップ
メニューが表示されているときは発行されない。
それ以外はCursorMovedと同じ。
*EncodingChanged*
EncodingChanged オプション 'encoding' が変更されたとき。例えば、
フォント等の設定に便利である。
*FileAppendCmd*
FileAppendCmd ファイルに追加する前。ファイルへの追加の役目を
負う。|Cmd-event|
*FileAppendPost*
FileAppendPost ファイルに追加した後。
*FileAppendPre*
FileAppendPre ファイルに追加する前。
*FileChangedRO*
FileChangedRO 読み込み専用ファイルに最初の変更を加える前。
ソース管理システム {訳注: CVSやRCS} からファイ
ルをチェックアウトするのに使われる。変更が自動
コマンドによるときには発生しない。
このイベントが発生するのは、バッファに最初の変
更を行うときや、'readonly'がセットされた後に最
初の変更を行うときの、変更が適用される直前であ
る。
警告: 自動コマンドでカーソルが動かされるときの
動作は、定義されていない。
*E788*
ここで他のバッファに変更をしてはならない。バッ
ファを再読み込みするのはよいが、他のバッファを
編集してはならない。
*E881*
行数が変化した場合 undo のための保存は失敗し、
その変更は中止されるだろう。
*DiffUpdated*
DiffUpdated 差分が更新された後。使用されているdiffコマンド
の種類(内部または外部)に応じて、変更毎か
Expand All @@ -758,6 +733,9 @@ DirChanged |:cd|, |:tcd| もしくは |:lcd| コマンドによって、
"auto" 'autochdir' により発生する
"drop" ファイルの編集により発生する
<afile> は新ディレクトリ名に設定される。
*EncodingChanged*
EncodingChanged オプション 'encoding' が変更されたとき。例えば、
フォント等の設定に便利である。
*ExitPre*
ExitPre Vim を終了させる `:quit`, `:wq` もしくは
`:qall` を使用したときで、|QuitPre| の直後。不
Expand All @@ -766,6 +744,31 @@ ExitPre Vim を終了させる `:quit`, `:wq` もしくは
合には、終了はまだキャンセルされる可能性があ
る。本当に終了するときのためには |VimLeavePre|
を使用すること。
*FileAppendCmd*
FileAppendCmd ファイルに追加する前。ファイルへの追加の役目を
負う。|Cmd-event|
*FileAppendPost*
FileAppendPost ファイルに追加した後。
*FileAppendPre*
FileAppendPre ファイルに追加する前。
*FileChangedRO*
FileChangedRO 読み込み専用ファイルに最初の変更を加える前。
ソース管理システム {訳注: CVSやRCS} からファイ
ルをチェックアウトするのに使われる。変更が自動
コマンドによるときには発生しない。
このイベントが発生するのは、バッファに最初の変
更を行うときや、'readonly'がセットされた後に最
初の変更を行うときの、変更が適用される直前であ
る。
警告: 自動コマンドでカーソルが動かされるときの
動作は、定義されていない。
*E788*
ここで他のバッファに変更をしてはならない。バッ
ファを再読み込みするのはよいが、他のバッファを
編集してはならない。
*E881*
行数が変化した場合 undo のための保存は失敗し、
その変更は中止されるだろう。
*FileChangedShell*
FileChangedShell ファイルのタイムスタンプが、ファイルの編集が始
まってから変更されたことを発見したとき。
Expand Down Expand Up @@ -1190,6 +1193,9 @@ TextChangedP 挿入モードでカレントバッファのテキストが変
TextYankPost カレントバッファでテキストがヤンクもしくは削除
された後。|v:event| の以下の値は、この autocmd
を発生させた操作を特定するのに使用できる:
inclusive 移動が |inclusive| の時に真と
なり、|exclusive| のときはそう
ではない。
operator 実行されたオペレータ。
regcontents レジスタに格納された行区切りの
テキストのリスト。以下と同様: >
Expand Down
80 changes: 43 additions & 37 deletions en/autocmd.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*autocmd.txt* For Vim version 8.2. Last change: 2022 Apr 08
*autocmd.txt* For Vim version 8.2. Last change: 2022 Apr 17


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -95,6 +95,7 @@ Or use `:execute`: >
:augroup mine | exe "au! BufRead *" | augroup END
:augroup mine | exe "au BufRead * set tw=70" | augroup END

< *autocmd-expand*
Note that special characters (e.g., "%", "<cword>") in the ":autocmd"
arguments are not expanded when the autocommand is defined. These will be
expanded when the Event is recognized, and the {cmd} is executed. The only
Expand Down Expand Up @@ -473,13 +474,15 @@ BufRead or BufReadPost When starting to edit a new buffer, after
executing the modelines. See |BufWinEnter|
for when you need to do something after
processing the modelines.
This does NOT work for ":r file". Not used
when the file doesn't exist. Also used after
successfully recovering a file.
Also triggered for the filetypedetect group
when executing ":filetype detect" and when
writing an unnamed buffer in a way that the
buffer gets a name.
Also triggered:
- when writing an unnamed buffer in a way that
the buffer gets a name
- after successfully recovering a file
- for the filetypedetect group when executing
":filetype detect"
Not triggered:
- for the `:read file` command
- when the file doesn't exist
*BufReadCmd*
BufReadCmd Before starting to edit a new buffer. Should
read the file into the buffer. |Cmd-event|
Expand Down Expand Up @@ -707,9 +710,38 @@ CursorMoved After the cursor was moved in Normal or Visual
CursorMovedI After the cursor was moved in Insert mode.
Not triggered when the popup menu is visible.
Otherwise the same as CursorMoved.
*DiffUpdated*
DiffUpdated After diffs have been updated. Depending on
what kind of diff is being used (internal or
external) this can be triggered on every
change or when doing |:diffupdate|.
*DirChangedPre*
DirChangedPre The working directory is going to be changed,
as with |DirChanged|. The pattern is like
with |DirChanged|. The new directory can be
found in v:event.directory.
*DirChanged*
DirChanged The working directory has changed in response
to the |:cd| or |:tcd| or |:lcd| commands, or
as a result of the 'autochdir' option.
The pattern can be:
"window" to trigger on `:lcd`
"tabpage" to trigger on `:tcd`
"global" to trigger on `:cd`
"auto" to trigger on 'autochdir'.
"drop" to trigger on editing a file
<afile> is set to the new directory name.
*EncodingChanged*
EncodingChanged Fires off after the 'encoding' option has been
changed. Useful to set up fonts, for example.
*ExitPre*
ExitPre When using `:quit`, `:wq` in a way it makes
Vim exit, or using `:qall`, just after
|QuitPre|. Can be used to close any
non-essential window. Exiting may still be
cancelled if there is a modified buffer that
isn't automatically saved, use |VimLeavePre|
for really exiting.
*FileAppendCmd*
FileAppendCmd Before appending to a file. Should do the
appending to the file. Use the '[ and ']
Expand Down Expand Up @@ -737,35 +769,6 @@ FileChangedRO Before making the first change to a read-only
*E881*
If the number of lines changes saving for undo
may fail and the change will be aborted.
*DiffUpdated*
DiffUpdated After diffs have been updated. Depending on
what kind of diff is being used (internal or
external) this can be triggered on every
change or when doing |:diffupdate|.
*DirChangedPre*
DirChangedPre The working directory is going to be changed,
as with |DirChanged|. The pattern is like
with |DirChanged|. The new directory can be
found in v:event.directory.
*DirChanged*
DirChanged The working directory has changed in response
to the |:cd| or |:tcd| or |:lcd| commands, or
as a result of the 'autochdir' option.
The pattern can be:
"window" to trigger on `:lcd`
"tabpage" to trigger on `:tcd`
"global" to trigger on `:cd`
"auto" to trigger on 'autochdir'.
"drop" to trigger on editing a file
<afile> is set to the new directory name.
*ExitPre*
ExitPre When using `:quit`, `:wq` in a way it makes
Vim exit, or using `:qall`, just after
|QuitPre|. Can be used to close any
non-essential window. Exiting may still be
cancelled if there is a modified buffer that
isn't automatically saved, use |VimLeavePre|
for really exiting.
*FileChangedShell*
FileChangedShell When Vim notices that the modification time of
a file has changed since editing started.
Expand Down Expand Up @@ -1205,6 +1208,9 @@ TextYankPost After text has been yanked or deleted in the
current buffer. The following values of
|v:event| can be used to determine the operation
that triggered this autocmd:
inclusive TRUE if the motion is
|inclusive| else the motion is
|exclusive|.
operator The operation performed.
regcontents Text that was stored in the
register, as a list of lines,
Expand Down