Wednesday, December 9, 2009

Vimgrep Tips

I've mentioned vimgrep in a previous post, but I neglected to mention a few useful flags that can be used in conjunction with it.

If you apply the 'g' flag to your vimgrep, it will return all matches instead of just one match per line.

:vimgrep /foo/g **/*

If you apply the 'j' flag, Vim will not automatically jump to the first match.

:vimgrep /foo/j **/*

Thanks to Chanel for pointing these out.

7 comments:

Marc said...

Thank you, :vimgrep with :cope are great features :-)

Charles Binford said...

:vimgrep wants a filename. If you just want to search in the current buffer use '%'. e.g. :vimgrep /foo/ %

Travis Whitton said...

@Charles

Doh, typo. Thanks for the heads up.

Tomasz said...

:lvimgrep may be more handy in many cases; i find it totally useful with C, when it uses location list instead of quickfix list, so the grep results don't get cleared every time i re-compile.

still, :lope, :cope, :vimgrep or :lvimgrep are totally powerful and handy :)

Slava said...

Thanks, useful stuff for a beginner. Didn't knew about :vimgrep feature. Keep the good work mate :)

Cheap Viagra said...

Vimgrep Tips? Wow it could be perfect for me because I don't know much about it, but I want to increase my knowledge thanks.

Lotus said...

heynow, this is the most recent "Daily Vim" post? I want my daily dose of vim coolness! :)