Tuesday, December 6, 2011

Global search in vi and list results

We use the simple command to search a pattern (or a fragment of text),

:/{pattern}

Sometimes, there would be a few dozens of matches that you want to list and browse quickly.  Use this command,

:g/{pattern}

It lists the search results in one buffer.  If you want to search the pattern case insensitive, add \c in the command, like

:g/\c{pattern}

No comments:

Post a Comment