Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim Editing - how to edit the highlighted segment of a search or convert to visual block

Tags:

vim

In vim, if I have the following text:

hello there

Say I search for hell in the text above.

/hell

and press n to move to the next instance.

hello

hell is now highlighted in vim and my cursor is on the 'h'.

What is the most efficient way to now yank/delete that highlighted text.

Is there a way to 'yank to the end of the highlighted text'? Or 'create visual block from highlighted text'?

I know I can use %s/hell/whatever/gc to step through as an alternative.

TIA Tom

like image 218
Tom Howe Avatar asked Jan 22 '23 11:01

Tom Howe


1 Answers

y//e, or d//e should do the trick.

:let @" = @/ as well, even if you have moved the cursor.

like image 66
Luc Hermitte Avatar answered Jan 28 '23 06:01

Luc Hermitte