搜索后,如果您点击 //
,你似乎得到了下一个结果。这与 n
有何不同?你应该如何使用它?什么//e
匹配,以及 //
还有哪些其他选项?
最佳答案
搜索命令的格式如下:
/pattern/offset<cr>
如果
pattern
部分被遗漏,搜索将查找最后搜索的模式。如果省略偏移量,则不应用偏移量。偏移量基本上是您找到 pattern
后对光标执行的操作。元素。最
vi
用户熟悉没有偏移的变化,/pax<cr>
并重复上次搜索,/<cr>
,相当于 n
.在您的具体示例中,
//<cr>
与 /<cr>
相同这意味着重复上次搜索并且不应用偏移量。另一方面,
//e<cr>
表示重复上次搜索并将光标移动到找到的项目的末尾。偏移量是:[num] [num] lines downwards, in column 1
+[num] [num] lines downwards, in column 1
-[num] [num] lines upwards, in column 1
e[+num] [num] characters to the right of the end of the match
e[-num] [num] characters to the left of the end of the match
s[+num] [num] characters to the right of the start of the match
s[-num] [num] characters to the left of the start of the match
b[+num] [num] identical to s[+num] above (mnemonic: begin)
b[-num] [num] identical to s[-num] above (mnemonic: begin)
;{pattern} perform another search, see |//;|
没有
num
的加号或减号用途 1
.
关于search - 搜索命令 `//` 在 Vim 中是如何工作的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3984622/