File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change 1
- *autocmd.txt* For Vim バージョン 9.1. Last change: 2025 Apr 21
1
+ *autocmd.txt* For Vim バージョン 9.1. Last change: 2025 Jun 19
2
2
3
3
4
4
VIMリファレンスマニュアル by Bram Moolenaar
@@ -127,6 +127,10 @@ Note ":autocmd" の引数の中の特別な文字 (例えば "%" や "<cword>"
127
127
:au BufNewFile,BufRead *.html so <sfile>:h/html.vim
128
128
129
129
ここで <sfile> は、この行を含むファイルの名前に展開される。
130
+ ただし、<sfile> は関数内では異なる動作をするため、同じ目的を達成するには
131
+ <script> とともに `:execute ` を使用する方が適切である: >
132
+ >
133
+ :exe $'au BufNewFile,BufRead *.html so {expand("<script>:h")}/html.vim'
130
134
131
135
`:autocmd ` は、すでに存在しているかどうかにかかわらず、自動コマンドのリストに
132
136
追加する。.vimrc ファイルが2回読み込まれると、自動コマンドが2回表示される。こ
Original file line number Diff line number Diff line change 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
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -130,6 +130,10 @@ exception is that "<sfile>" is expanded when the autocmd is defined. Example:
130
130
:au BufNewFile,BufRead *.html so <sfile>:h/html.vim
131
131
132
132
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'
133
137
134
138
`:autocmd ` adds to the list of autocommands regardless of whether they are
135
139
already present. When your .vimrc file is sourced twice, the autocommands
You can’t perform that action at this time.
0 commit comments