Vim Tips Wiki
Register
(redirect to merged page)
 
Line 1: Line 1:
  +
#REDIRECT [[Search_for_lines_not_containing_pattern_and_other_helpful_searches#Using_the_:v_command]]
 
{{duplicate|220|802}}
 
{{duplicate|220|802}}
 
{{TipImported
 
{{TipImported

Latest revision as of 15:28, 1 July 2013

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:

/^\(.*Warning\)\@!.*$

or

/\v^(.*Warning)@!.*$

Comments[]

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):

:v/Warning/p

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":

:v/warning/d