Vim: How do I search for a word which is not followed by another word?

后端 未结 4 1731
北恋
北恋 2020-12-23 14:09

Pretty basic question, I\'m trying to write a regex in Vim to match any phrase starting with \"abc \" directly followed by anything other than \"defg\"

4条回答
  •  一个人的身影
    2020-12-23 14:28

    Here we go, this is a hairy one:

    /\%(\%(.\{-}\)\@<=XXXXXX\zs\)*
    

    (replace XXXXXX with the search word). This will search for everything that does not contain XXXXXX. I imagine if you did:

    /abc \%(\%(.\{-}\)\@<=defg\zs\)*
    

    This may work like you want it to. Hope this helps a little!

提交回复
热议问题