gearsin
gearsin

Reputation:

Search through set of files designated by multiple globs with Vimgrep

Does anyone know syntax of Vimgrep to search with multiple file globs? I am trying to use this command to search in the current directory.

map <F3> :execute "vimgrep /" . expand("<cword>") . "/j **/*.c* *.txt" <Bar> cw<CR>

With using this command, Vim searches only for *.c*. Any idea about how to search for multiple filetypes?

Upvotes: 12

Views: 6358

Answers (3)

Scott Radcliff
Scott Radcliff

Reputation: 1551

I am just getting into Vim and this question taught me about the existence of vimgrep. Is there a way to loop through the results? So say I wanted to find all of the instances of "user", and I use

:vimgrep /user/g **/*.rb

How could I loops through the instances of that text?

Upvotes: 0

Naga Kiran
Naga Kiran

Reputation: 8765

To search for "text" in all *.txt & *.php files recursively from current directory.

:vimgrep "text" **/*.txt **/*.php

Upvotes: 25

Adrian Panasiuk
Adrian Panasiuk

Reputation: 7363

in this directory

:vimgrep "search subject" *.c
:vimgrep blah *.[ch]
:vimgrep blah *.c* *.h

in this or any descendant directory

:vimgrep "search subject" ./**/*.c

Upvotes: 4

Related Questions