在vim中搜索选择 [英] Search for selection in vim
问题描述
在编写C ++时,我在Visual Studio中使用vim和vim插件.通常,我发现自己想在函数中搜索字符串,例如,每次对object->public_member.memberfunc()
的调用.
I use vim and vim plugins for visual studio when writing C++. Often, I find myself wanting to search for a string within a function, for example every call to object->public_member.memberfunc()
.
我知道vim通过按*
和#
提供了一种搜索单个单词的便捷方法,它还可以使用无处不在的斜杠/
命令搜索键入的字符串.尝试搜索较长字符串的所有实例(如上述实例)时,在/
之后重新键入会花费一些时间.
I know vim offers a convenient way to search for a single word, by pressing *
and #
, and it can also search for typed strings using the ubiquitous slash /
command. When trying to search for all the instances of a longer string like the one above, it takes a while to re-type after /
.
有没有一种搜索选择的方法?例如,用v
突出显示,然后用y
复制,是否可以在/
之后粘贴?有更简单的快捷方式吗?
Is there a way to search for selection? For example, highlight with v
, then copy with y
, is there a way to paste after /
? Is there an easier shortcut?
推荐答案
检查以下Vim技巧:在视觉上进行搜索选定的文字
Check this Vim tip: Search for visually selected text
或者您可以简单地用 y 拉动所选文本并进入搜索模式/,然后可以用 Ctrl + R 0粘贴最后拉动的文本.
Or you can simply yank the selected text with y and go to search mode /, then you can paste the last yanked text with Ctrl+R 0
这篇关于在vim中搜索选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!