在 Vim 中搜索选择 [英] Search for selection in Vim

查看:16
本文介绍了在 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 the 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆