search - 搜索命令 `//` 在 Vim 中是如何工作的?

标签 search vim keyboard-shortcuts

搜索后,如果您点击 // ,你似乎得到了下一个结果。这与 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/

相关文章:

c - 在 C 中实现排序数组的二进制搜索

vim - 自动格式化时如何使vim不打断字符串?

vim - clang_complete 的异步代码完成

python - wxPython菜单文本对齐

javascript - 是否可以使用 Jquery 模拟 Ctrl+F 组合键?

java - 为 A* 搜索计算 f_score[neighbor]

django - aldryn-search for Django CMS 搜索全文

vim - 空行可以在 Vim 中显示为其他内容吗?

javascript - 如何实现用户可自定义的键盘快捷键(在 javascript 中/在网络上)

Azure 搜索 - 使用 lucene 和过滤器