在 vim 中使用增量搜索时,光标会立即转到下一次出现的搜索词,只要您输入它。 Emacs 也有类似的增量搜索功能。然而,我发现 emacs isearch 有一个非常有用的功能,我真的很喜欢 vim。在 emacs 中,如果您键入:<ctrl-s>word
它立即转到“单词”,就像 vim 增量搜索一样。在 emacs 中,您现在可以输入附加 <ctrl-s>
移动到“word”的下一个结果出现处,在 emacs 中,这不会结束您的增量搜索 session 。要在 vim 中执行相同操作,您必须点击 <cr>
, 结束搜索词,然后点击 n
转到下一个搜索结果。因为 emacs 不会结束搜索 session ,所以您可以执行以下操作:<ctrl-s>word<ctrl-s><ctrl-s>more
一旦您靠近想要去的地方,这让您可以“回到原点”进行搜索,结果证明它非常有用!
有没有办法让vim做同样的事情?
最佳答案
最新版本的 Vim 提供了命令行模式的内置映射,以完全满足您的需求。
您可以在 help 中找到此信息:
CTRL-G
When
'incsearch'
is set, entering a search pattern for"/"
or"?"
and the current match is displayed then CTRL-G will move to the next match (does not take search-offset into account). Use CTRL-T to move to the previous match. Hint: on a regular keyboard T is above G.
补丁号供引用,因为并非所有安装都有映射:
关于vim - 如何像在 Emacs 中那样在 Vim 中进行增量搜索?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40192919/