如何使用 vim 在选定的代码块中搜索 [英] How do I search within a selected block of code with vim
本文介绍了如何使用 vim 在选定的代码块中搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
比如说,我想搜索带有功能块的特定文本.目前,我正在实施的方法是使用 vi{
从函数括号内选择代码块,然后将其复制并粘贴到新文件中.之后,我使用 /
say, I want to search for a particular text withing a function block.
The present way, that i am implementing is selecting the block of code from within the function brackets with vi{
and then copying it and pasting it to a new file. After that I am searching for the text within the new file with /<search-text>
我想知道,是否有捷径可走?
I want to know, if there is a short cut to this?
推荐答案
vi{
:'<,'>g/foo/#
'<,'>
范围是自动插入的.
参见 :help range
和 :help :g
.
这篇关于如何使用 vim 在选定的代码块中搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文