3

The / command moves to the next occurrence of a pattern. But how do I move to the next line in which a pattern does not appear?

  • You might have a look here. – cbaumhardt Aug 27 '15 at 17:57
  • 1
    ... which gives something like /\v^((pattern)@!.)*$ – VanLaser Aug 27 '15 at 18:03
5

Recent Vims come with the LogiPat plugin. With that, you can simply do

:LogiPat !"foo"

and it will jump to the next line, not containting your pattern. To see the pattern, you can type

:echo @/

which should show something like ^\%(\%(foo\)\@!.\)*$

  • 1
    TIL :LogiPat :) – VanLaser Aug 27 '15 at 19:03
  • Beware however that the patterns produced by LogiPat are not always perfect (cf. :help logipat-caveat). "Negating" regexps is always tricky, and LogiPat is not a silver bullet. – Sato Katsura Aug 27 '15 at 19:05
  • @SatoKatsura True – Christian Brabandt Aug 27 '15 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.