(親記事はコチラ Vimコマンド&Script入門)
vimgrepの次はlvimgrepです。
ヘルプを見てみます。。
:h lvimgrep
*:lv* *:lvimgrep*
:lv[imgrep][!] /{pattern}/[g][j] {file} ...
:lv[imgrep][!] {pattern} {file} ...
Same as ":vimgrep", except the location list for the
current window is used instead of the quickfix list.
quickfix listの代わりに、カレントウィンドウのlocation listを使うことを除けば、:vimgrepと同じのようですね。
では実験用のファイルを作成。
/tmp $ rm test*
/tmp $ for i in {1..5};do echo HELLO$i>test_$i.txt;done
/tmp $ vim test_1.txt test_2.txt
test_1.txtとtest_2.txtのみをVimで開きました。
test_1.txtにはHELLO1、test_2.txtにはHELLO2が格納されています。
lvimgrepでHELLOを検索してみます。
:lvimgrep HELLO test*

あれ、どうしたことでしょうか。1 of 5とあるので、5個見つかっています。
test_1.txtとtest_2.txtしか開いていないはずなのに。
location-listのヘルプを確認してみます。
:h location
*location-list* *E776*
A location list is a window-local quickfix list. You get one after commands
like `:lvimgrep`, `:lgrep`, `:lhelpgrep`, `:lmake`, etc., which create a
location list instead of a quickfix list as the corresponding `:vimgrep`,
`:grep`, `:helpgrep`, `:make` do.
*location-list-file-window*
A location list is associated with a window and each window can have a
separate location list. A location list can be associated with only one
window. The location list is independent of the quickfix list.
When a window with a location list is split, the new window gets a copy of the
location list. When there are no longer any references to a location list,
the location list is destroyed.
location-listに関して、誤解してました。基本的に、quickfix listと同じで、ウィンドウローカルなだけなんですね。



コメント