shell

Greping from inside Vim

Hi there,
First things first: Happy New Year! :)
One task I usually perform when I am writing code is grepping the code for a certain string. In order to do that, I used to exit Vim (either with :q or suspending the process), grep the files and then go back to my Vim session. This approximation has one main drawback: I usually don’t remember all the matches reported by grep.
Vim provides a mechanism for invoking grep from a Vim session. The command is:

:grep string files

This way, one can invoke his local grep command and the results will be integrated into the error list, the one we wrote about in compilation errors. This way, one can move through the matching list using both :cp and :cn
We can instruct Vim to use another grep program by setting the grepprg variable.

speak up

Add your comment below, or trackback from your own site.

Subscribe to these comments.

Be nice. Keep it clean. Stay on topic. No spam.

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

*Required Fields