It happens sometimes that I have to look into various log and trace files on Windows and generally I use for the purpose VIM.
My problem though is that I still can’t find any analog of grep -v inside of VIM: find in the buffer a line not matching given regular expression. E.g. log file is filled with lines which somewhere in a middle contain phrase all is ok and I need to find first line which doesn’t contain all is ok.
I can write a custom function for that, yet at the moment that seems to be an overkill and likely to be slower than a native solution.
Is there any easy way to do it in VIM?
you can use negative look-behind operator
@<!e.g. to find all lines not containing “a”, use
/\v^.+(^.*a.*$)@<!$(
\vjust causes some operators like(and@<!not to must have been backslash escaped)the simpler method is to delete all lines matching or not matching the pattern (
:g/PATTERN/dor:g!/PATTERN/drespectively)