Vim Tips Wiki

Search for lines not containing pattern

Revision as of 23:20, April 30, 2011 by (Talk)

1,619pages on
this wiki

Duplicate tip

This tip is very similar to the following:

These tips need to be merged – see the merge guidelines.

Tip 1180 Printable Monobook Previous Next

created March 21, 2006 · complexity basic · author Bertram Scharpf · version 6.0

When examining a long log file, you might want to find lines not containing a word. For lines not containing "Warning", the search command is:





You might want to add a little note on matching, as the manual states..."Using "\@!" is tricky, because there are many places where a pattern does not match".

If you want to see all such lines at once, there's the traditional (but simple):


A neat trick when working with a large log file where you want to filter out as many irrelevant lines as possible before you get started on your real search is:

:sav junk.log

Now you are editing a clone of your original file and can mess about at will. For example, the following will delete all lines that do not contain the text "warning":


Around Wikia's network

Random Wiki