Tip 111Grep with Vim’s Internal Search Engine

The :vimgrep command allows us to search through multiple files using Vim’s native regular expression engine.

As a demonstration, we’ll use the files in the grep/quotes directory, which you can find in the source files that come distributed with this book. The directory contains the following files, reproduced here with their contents:

 quotes/
  about.txt
  Don't watch the clock; do what it does. Keep going.
 
  tough.txt
  When the going gets tough, the tough get going.
 
  where.txt
  If you don't know where you are going,
  you might wind up someplace else.

Each of these files contains at least one occurrence of the word “going.” We can ask Vim to search for that word in each of those files ...

Get Practical Vim, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.