Eric Leenman wrote:
I have a file where I deleted all lines that don't contain a certain
pattern
For example I want to delete all lines that don't contain XXX and YYY.
:g/PATTERN/cmd
executes the given command on all lines containing the PATTERN.
:v/PATTERN/cmd
executes the given command on all lines _not_ containing the PATTERN.
You can use LogiPat to set up patterns with boolean logic involved:
:echo LogiPat('"XXX"&"YYY"')
which yields:
\%(.*XXX.*\&.*YYY.*\)
The \%( and trailing ) are not needed in this case, but the pattern will,
nonetheless, work. You can get LogiPat from either
http://mysite.verizon.net/astronaut/vim/index.html#VimFuncs -- "LogiPat"
http:////vim.sourceforge.net/scripts/script.php?script_id=1290
So if you want to delete all patterns not having XXX and YYY, then
:v/\%(.*XXX.*\&.*YYY.*\)/d
would do the trick.
Regards,
Chip Campbell