Lets say there is some block of text that I want to search for in the file. Is there a way to make a visual-block selection of that text and then make it the current search term? That way I'd be able to do s//replacementText/g without typing the whole thing on the left side of the substitute command.
Make a visual block and yank it to the unnamed register ""
: with a visual block selected, type y
to yank. Begin the search with /
- or :s/
and type Ctrl-r
then "
to insert the contents of the unnamed register as the search term.
This won't make the block the current search, but it's nearly as easy.
Ctrl-r
can be used anywhere in the command-line, so you can also use this e.g. to fill in the substitution or replacement text, or in insert mode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With