Is there a way to do negative lookahead in vim regex?
I always find it weird, that you need to escape brackets in vim, so I try to use the "very magic" mode most of the time, activated with \v
:
/\vabc(.*xyz)@!
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.