Is there a way to search for multiple strings simultaneously in Vim? I recall reading somewhere that it was possible but somehow forgot the technique.
So for example, I have a text file and I want to search for "foo" and "bar" simultaneously (not necessarily as a single string, can be in different lines altogether).
How do I achieve that?
Finding a whole word Simply move the cursor anywhere within the word, then press * to search for the next occurrence of that whole word. Vim inserts \< and \> automatically (see searching). The pattern \<i finds all words that start with "i", while i\> finds all words that end with "i".
^ * $ \ ? ) have special significance to the search process and must be “escaped” when they are used in a search. To escape a special character, precede it with a backslash ( \ ). For example, to search for the string “anything?” type /anything\? and press Return.
/^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line)
/fred\|joe : Search for FRED OR JOE
Actually I found the answer soon after I posted this (yes I did google earlier but was unable to locate it. Probably was just searching wrong)
The right solution is
/(foo\|bar)
@Paul Betts: The pipe has to be escaped
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With