How can I search for 3 strings at a time in the vi editor?
I was wonderi开发者_StackOverflow社区ng 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.
精彩评论