Questions tagged [vimgrep]
35 questions
59
votes
2 answers
How to jump between patterns when using :vimgrep (Quickfix list)?
I am new to vim, and still exploring some features of it. I have a problem with vimgrep. I can search for a pattern like this vimgrep /define/ ** so that it finds and opens next file that contains a define. But I couldn't yet find out how to go to…

yasar
- 13,158
- 28
- 95
- 160
34
votes
5 answers
How to exclude file patterns in vimgrep?
In vim, I do search with vimgrep frequently. I have mapping like below:
map s :execute "noautocmd vimgrep /\\<" . expand("") . "\\>/gj **/*.*"
cw 5
The problem is that there are some temporary subfolders (like obj, objd)…

Morgan Cheng
- 73,950
- 66
- 171
- 230
27
votes
1 answer
ag Silver Searcher: rules for lookahead/lookbehind patterns?
I'm using ag in Vim with good results for string/file search.
However, there seems to be not much documentation how patterns are constructed for ag.
I'm trying to use ag instead of vimgrep in an example from the Practical Vim book.
I want to find…

user3156459
- 1,123
- 2
- 9
- 17
12
votes
3 answers
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 :execute "vimgrep /" . expand("") . "/j **/*.c* *.txt" cw
With using this command,…
gearsin
9
votes
3 answers
Is there a shorter key combination than :cn to go to the next item in the quickfix list?
I'm reading through a large C++ code base in Vim.
Within a single file, I can do
/foo
n
n
n
Now, if I want to search through more than one file, I have to do:
:vimgrep /foo/
:cn
:cn
:cn
Now, typing :cn is so much less convenient than n. Is there a…

anon
- 41,035
- 53
- 197
- 293
6
votes
1 answer
Why is **/* used to search recursively through current directory in :vimgrep vim command?
Why do they use the double asterisk?
I've read Vim's help on vimgrep, I've looked around on stack overflow and vimcasts and whilst I have found lots of people saying that this is how you search recursively in current directory, I haven't found an…

Stun Brick
- 1,124
- 6
- 17
6
votes
3 answers
vim quickfix list: manipulate location?
When I am working with vim, I occasionally end up with a split menu setup like this:
###############################################
# | | #
# | | #
# NERDTree | …

daniel451
- 10,626
- 19
- 67
- 125
5
votes
1 answer
Use Multiple Patterns in Vimgrep in Key Mapping
In my vimrc I had a mapping to find all line with TODO in them and put them in the quickfix window:
nnoremap f :vimgrep /TODO/j % \| :cw
I now want to add the alternative pattern FIXME in the same way. So I tried
nnoremap f…

PaulM
- 446
- 2
- 12
5
votes
2 answers
How do I write a vim function that calls VimGrep?
I want to write a function myFunc such that:
myFunc /function foo/
becomes
:vimgrep /function foo/ **/*.cpp **/*.hpp
and
myFunc /class bar: public/
becomes
vimgrep /class bar: public/ **/*.cpp **/*.hpp
how do I do this?
Thanks!

anon
- 41,035
- 53
- 197
- 293
5
votes
3 answers
Is it possible to use vimgrep for a visual selection of the current file?
I would like to search with vimgrep only within a visual selection of the current file and not the whole file. Is that possible and how? I couldn't find something for this case with Google or in vim help.
The reason why I want this is because I need…

Cutú Chiqueño
- 855
- 1
- 10
- 24
4
votes
2 answers
What's a quickfix window and how to use it?
I just found out how to use vimgrep command to search for a particular string in multiple files. I know that the search results are stored in quickfix
I use :cnext to go to the next matching pattern. But this is not a feasible option if there are…

Sagar Jain
- 7,475
- 12
- 47
- 83
4
votes
1 answer
How to make vimgrep do word match search?
I have below statement in _vimrc file to map F3 to do vimgrep for word under current cursor.
map :execute "noautocmd vimgrep /" . expand("") . "/gj **/*." . expand("%:e") cw
Now, I want to make it vimgrep for exact word match…

Morgan Cheng
- 73,950
- 66
- 171
- 230
3
votes
4 answers
is there any way to vimgrep, limiting to >1 but not all types of files?
i'm pretty used to doing either:
:vimgrep /whatever/ **/*
or
:vimgrep /whatever/ **/*.txt
but is there a way with vim globbing to do, say, 2 file types? i guess i want something that would work kind of like this:
:vimgrep /whatever/…

subrama6
- 517
- 1
- 5
- 20
3
votes
3 answers
VIM - Hotkey for VIMGREP on Visual Selection in current buffer
How would I go about setting up a hotkey (eg: CTRL+g) to perform a VIMGREP operation on the current visual selection in the current buffer? My intent is to show a line-numbered list in the "quickfix" window of all matching search results.
Right…

Cloud
- 18,753
- 15
- 79
- 153
3
votes
2 answers
How to recursively grep the pattern inside the directory?
I would like to grep all string patterns which are start with the:
student_
, then
any numbers of symbols(letters and digits)
and end with the
.tcl

Vardan Hovhannisyan
- 1,101
- 3
- 17
- 40