Skip to content

Update autocmd.{txt,jax} #2110

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2025
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
6 changes: 5 additions & 1 deletion doc/autocmd.jax
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*autocmd.txt* For Vim バージョン 9.1. Last change: 2025 Apr 21
*autocmd.txt* For Vim バージョン 9.1. Last change: 2025 Jun 19


VIMリファレンスマニュアル by Bram Moolenaar
Expand Down Expand Up @@ -127,6 +127,10 @@ Note ":autocmd" の引数の中の特別な文字 (例えば "%" や "<cword>"
:au BufNewFile,BufRead *.html so <sfile>:h/html.vim

ここで <sfile> は、この行を含むファイルの名前に展開される。
ただし、<sfile> は関数内では異なる動作をするため、同じ目的を達成するには
<script> とともに `:execute` を使用する方が適切である: >
>
:exe $'au BufNewFile,BufRead *.html so {expand("<script>:h")}/html.vim'

`:autocmd` は、すでに存在しているかどうかにかかわらず、自動コマンドのリストに
追加する。.vimrc ファイルが2回読み込まれると、自動コマンドが2回表示される。こ
Expand Down
6 changes: 5 additions & 1 deletion en/autocmd.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
*autocmd.txt* For Vim version 9.1. Last change: 2025 Apr 21
*autocmd.txt* For Vim version 9.1. Last change: 2025 Jun 19


VIM REFERENCE MANUAL by Bram Moolenaar
Expand Down Expand Up @@ -130,6 +130,10 @@ exception is that "<sfile>" is expanded when the autocmd is defined. Example:
:au BufNewFile,BufRead *.html so <sfile>:h/html.vim

Here Vim expands <sfile> to the name of the file containing this line.
However, <sfile> works differently in a function, in which case it's better to
use `:execute` with <script> to achieve the same purpose:
>
:exe $'au BufNewFile,BufRead *.html so {expand("<script>:h")}/html.vim'

`:autocmd` adds to the list of autocommands regardless of whether they are
already present. When your .vimrc file is sourced twice, the autocommands
Expand Down