Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to make yanks visual in vim?

Tags:

vim

When yanking in vim, there is no visual indication of the yank that you just made. Aside from inspecting the registers, does anyone know of a setting or plugin that will make vim highlight the region of the editor that was just yanked?

Tried googling, but if it's out there, I'm using the wrong phrase to search.

like image 718
DannoHung Avatar asked Nov 05 '25 12:11

DannoHung


2 Answers

You can probably use '[ and '] that mark the beginning and end of the last yanked text but what is your purpose, exactly? Do you want to verify if what you've actually yanked corresponds to what you wanted to yank? Please clarify your question.

What you can do, instead, is reverse the whole process:

  1. use visual mode or visual-line mode to select visually what you want to yank
  2. yank it

This way you know exactly what you are going to yank and you can re-select it with gv.

like image 164
romainl Avatar answered Nov 07 '25 14:11

romainl


How so?

Apart from yanking word or a line, when you generally know what you yanked, most of the yanks are done via visual or block mode, and in those you know what is yanked because it is selected prior to yanking.

But that aside, like you said, you can view the registers, or you can install a plugin like YankRing (or some of its more simple coutnerparts). It gives you a wonderful feature to quickly (pff, unless you used some multiple clipboard manager, this is a bit harder to explain) switch between yanked texts. You press, p for paste, and from there you choose by let's say Ctrl-p what you want to yank in place. It's an amazingly practical and easy to get used to feature.

like image 43
Rook Avatar answered Nov 07 '25 16:11

Rook



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!