Skip to content

Commit cbd39a7

Browse files
authored
Merge pull request #2110 from h-east/update-autocmd
Update autocmd.{txt,jax}
2 parents 0763a90 + 60d16d4 commit cbd39a7

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

doc/autocmd.jax

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*autocmd.txt* For Vim バージョン 9.1. Last change: 2025 Apr 21
1+
*autocmd.txt* For Vim バージョン 9.1. Last change: 2025 Jun 19
22

33

44
VIMリファレンスマニュアル by Bram Moolenaar
@@ -127,6 +127,10 @@ Note ":autocmd" の引数の中の特別な文字 (例えば "%" や "<cword>"
127127
:au BufNewFile,BufRead *.html so <sfile>:h/html.vim
128128
129129
ここで <sfile> は、この行を含むファイルの名前に展開される。
130+
ただし、<sfile> は関数内では異なる動作をするため、同じ目的を達成するには
131+
<script> とともに `:execute` を使用する方が適切である: >
132+
>
133+
:exe $'au BufNewFile,BufRead *.html so {expand("<script>:h")}/html.vim'
130134
131135
`:autocmd` は、すでに存在しているかどうかにかかわらず、自動コマンドのリストに
132136
追加する。.vimrc ファイルが2回読み込まれると、自動コマンドが2回表示される。こ

en/autocmd.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*autocmd.txt* For Vim version 9.1. Last change: 2025 Apr 21
1+
*autocmd.txt* For Vim version 9.1. Last change: 2025 Jun 19
22

33

44
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -130,6 +130,10 @@ exception is that "<sfile>" is expanded when the autocmd is defined. Example:
130130
:au BufNewFile,BufRead *.html so <sfile>:h/html.vim
131131
132132
Here Vim expands <sfile> to the name of the file containing this line.
133+
However, <sfile> works differently in a function, in which case it's better to
134+
use `:execute` with <script> to achieve the same purpose:
135+
>
136+
:exe $'au BufNewFile,BufRead *.html so {expand("<script>:h")}/html.vim'
133137
134138
`:autocmd` adds to the list of autocommands regardless of whether they are
135139
already present. When your .vimrc file is sourced twice, the autocommands

0 commit comments

Comments
 (0)