How to search in a selected block of code using vim

let's say I want to find a specific text with a function block. The current way that I am implementing is to select a block of code from the square brackets of the function with vi{, then copy it and paste it into a new file. After that I search for text in a new file with/<search-text>

I want to know if there is a short answer to this?

+4
source share
3 answers
vi{
:'<,'>g/foo/#

The range is '<,'>set automatically.

See :help rangeand :help :g.

+7
source

I think this may be what you are looking for:

Search Limit for Vim Code

/\%Vsearch pattern, , , , , . , v , , .

, !

+3

vi.SE.

\%V ( , ), , vi{, . vi.SE .

0

All Articles