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
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回表示される。こ
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
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
135139already present. When your .vimrc file is sourced twice, the autocommands
You can’t perform that action at this time.
0 commit comments