How To Search for multiple multi-word strings in vim?

10,176

The \& atom does not do what you think it does. It allows to match two regular expression parts at the same position. To have both strings match in the same line, you need to allow for an arbitrary number of characters before the matches.

This is the pattern: /.*red\&.*blue/

For your example:

/.*\<hello world\>\&.*\<goodbye world\>/
Share:
10,176

Related videos on Youtube

sreya
Author by

sreya

Updated on September 18, 2022

Comments

  • sreya
    sreya over 1 year

    For example I'm trying to search for the occurence of both hello world and goodbye world in the same line. I've tried a bunch of difference iterations. For example, if you want to find one multi-word string you can throw it in brackets /\<hello world\> but I can't figure out how to have multiple check for multiple, multi word strings

    I've tried

    /\<\(hello world \& goodbye world\)\>

    nor does this

    /\<hello world\>\&\<goodbye world\>