In Vim, is there a way to search for lines that match say abc
but do not also contain xyz
later on the line? So the following lines would match:
Your attempt was pretty close; you need to pull the .*
that allows an arbitrary distance between the match and the asserted later non-match into the negative look-ahead:
/abc\(.*xyz\)\@!
I guess this works because the non-match is attempted for all possible matches of .*
, and only when all branches have been exhausted is the \@!
declared as fulfilled.