To be honest upfront, I wanted to use global to find the first non-matching line, as in

v,/usr/lib/, abort

(having slashes in the search pattern is the reason for using g instead of / — I'm editing a list of files)

Yes, I know there are other ways to do it. But is there something like an abort command that causes g to abort immediately and not process any more matches?

  • You're not using regular search (/) because you have slashes in your search term? You don't want to just escape the slashes? (/\/usr\/lib\/) – B Layer Jul 5 '20 at 15:51
  • 1
    AFAIK, only :throw or another unsuccessful command (which de facto throws something for any reason). – Matt Jul 5 '20 at 16:07
  • 3
    add an invalid command (or just use abort as command :). Not sure what you are trying to achieve – Christian Brabandt Jul 5 '20 at 16:11
  • It seems unfair that s,,, can change the delimiter, but / can't, so out of principle I want to find a way around. It seems that both using nosuchcmd or throw 'err' stop globaland leave the cursor on the match. I... guess that works. Though that's not a graceful exit – usretc Jul 5 '20 at 17:02
  • 1
    Please better explain what problem you want to solve. It seems a bit unusual to me. – Christian Brabandt Jul 5 '20 at 19:57

While looking for a different way to do achieve my initial goal (find next non-matching line), B Layer came up with :.,$v// vis: see https://vi.stackexchange.com/a/28540/30091

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.