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\>/
Related videos on Youtube
Author by
sreya
Updated on September 18, 2022Comments
-
sreya over 1 year
For example I'm trying to search for the occurence of both
hello world
andgoodbye 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 stringsI've tried
/\<\(hello world \& goodbye world\)\>
nor does this
/\<hello world\>\&\<goodbye world\>