如何在vi编辑器中一次搜索3个字符串?

时间:2022-04-29 07:11:55

How can I search for 3 strings at a time in the vi editor?

如何在vi编辑器中一次搜索3个字符串?

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.

我想知道我们怎么能这样做。即像我一样在vi中一次搜索3个字符串:: / xyz在命令模式下。

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?

我怎么能再添加2个字符串,以便光标停在三个中首先找到的字符串中,如果我们按下它,它将停在三个中找到第二个字符串的字符串中?

I suppose this would be very helpful in real time.

我想这对实时非常有帮助。

1 个解决方案

#1


10  

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.

请注意,冒号(:)不是必需的。在命令模式下,您只需键入斜杠(/);不需要先输入冒号。

#1


10  

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.

请注意,冒号(:)不是必需的。在命令模式下,您只需键入斜杠(/);不需要先输入冒号。