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.
From stackoverflow
-
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.Pascal : Strange that you have to escape the pipe symbol, which is the opposite from standard RegExp. $-)Stephan202 : @SanHolo: yes. This holds for e.g. parentheses and square brackets as well. I suppose the philosophy behind this is that most users will use the search functionality for "regular" (non-regexp) searches.Tim : See `:help magic` for more details on when you should escape special characters, and how you can change this.
0 comments:
Post a Comment