@Rich answered your question very well. However, judging by your example you may want to look into :vimgrep
/:grep
.
:vimgrep /pat/ %
:grep 'pat' %
Both :vimgrep
& :grep
will put the results into the quickfix list. Here are a few quickfix list commands to get you up and running fast:
- Use
:cnext
and :cprev
to move between your errors/matches. I suggest you map these commands.
:cfirst
and :clast
to go to the first and last error/matches respectively.
:copen
to open up the quickfix list in a window (:cclose
to close)
:cwindow
to open quickfix list window only if there are errors
:cc
to display the current error/match.
- Use
:cdo {cmd}
to run a command, {cmd}
on each quickfix entry.
- You can use
%
on the command-line to supply the current filename.
Vimcast episodes:
See the following Vimcasts episode:
For more help see the following:
:h quickfix
:h :cnext
:h :cfirst
:h :cope
:h :cwindow
:h :cc
:h :cdo
:h :_%