October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 109 | Call grep Without Leaving Vim |
Vim’s :grep command acts as a wrapper to an external grep (or grep-like) program. Using this wrapper, we can have grep search for a pattern across multiple files without leaving Vim, and then we can navigate the results using the quickfix list.
First we’ll step through a workflow where grep and Vim run independently without talking to each other. We’ll examine the weaknesses with this approach before considering an integrated solution that solves these problems.
Suppose that we’re working on something in Vim and we need to find every occurrence of the word “Waldo” in all files in the current directory. Leaving Vim, we run the following in the shell:
| => | $ grep -n Waldo ... |