How can I search for 3 strings at a time in the vi editor?
I was wondering how could we do it. I.e. search for 3 strings at a time in vi
like I do: :/xyz
in command mode.
How could I add 2 more strings so that the cursor will stop at a string which ever is found first among the three and if we press n
it will stop at the string that is found second among the three?
I suppose this would be very helpful in real time.
Use the bar (|
), escaped (i.e., with a backslash in front, so that it is not interpreted as a literal bar):
/string1\|string2\|string3
Note that the colon (:
) is not necessary. In command mode, you can just type a slash (/
); no need to type a colon first.
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