Say I have multiple blocks of the following code in a file (spaces is irrelavent):
sdgfsdg dfg
dfgdfgf ddfg
dfgdfgdfg dfgfdg
How do you find/highlight all the occurrences?
What I ideally want to do is to visually select the code block and then press search to find all occurrences.
The text being searched for is stored in the
/register. You can’t yank or delete directly into this register, but you can assign to it using `let’.Try this:
"ayto yank that highlighted selection into registera:let @/ = @ato copy registerainto the search register/At this point, all code matching your selection will be highlighted, and you can navigate through occurrences using n/N just as you would a regular search.
Of course, you can use any temporary register instead of
a. And it shouldn’t be too difficult to get this command sequence mapped for easy use.