4

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?

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

1 Answer 1

6

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\)\@!.\)*$

3
  • 1
    TIL :LogiPat :)
    – VanLaser
    Aug 27, 2015 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. Aug 27, 2015 at 19:05
  • @SatoKatsura True Aug 27, 2015 at 19:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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