:vimgrep続きです。
サンプルは同じです。
/tmp $ for i in {1..5};do echo HELLO$i>test_$i.txt;done
/tmp $ vim
今回は、数字を指定してvimgrepを使ってみます。
:3vimgrep HELLO *.txt

3番目に見つかった場所を開くかと思いきや、そうではなく、最大3個見つけくれたようです。
ヘルプを確認してみます。
:{count}vim[grep] ...
When a number is put before the command this is used
as the maximum number of matches to find. Use
":1vimgrep pattern file" to find only the first.
Useful if you only want to check if there is a match
and quit quickly when it's found.
Without the 'j' flag Vim jumps to the first match.
With 'j' only the quickfix list is updated.
With the [!] any changes in the current buffer are
abandoned.
Every second or so the searched file name is displayed
to give you an idea of the progress made.
Examples:
:vimgrep /an error/ *.c
:vimgrep /\<FileName\>/ *.h include/*
:vimgrep /myfunc/ **/*.c
For the use of "**" see |starstar-wildcard|.
ファイル数を増やして確認してみます。
/tmp $ for i in {1..100};do echo HELLO$i>test_$i.txt;done
/tmp $ vim
:99vimgrep HELLO *.txt

(1 of 99) とあるので、最大99箇所ですね。
この状態で、copenすると、
Quickfix Listにたくさん表示されました。


コメント