Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim copy/yank without leaving visual mode

Tags:

vim

In normal text edit after I select and copy, the selection stays still, so I can copy again quickly. But in vim when I press y in visual mode, I enter normal mode, so I need to select again. I want a quicker way.

Reasons: When testing a console app, I copy test data from text editor and paste into console. Then I find bugs and edit code, the clipboard may change and I need to copy and paste test data to test again

like image 345
bilabila Avatar asked Jan 29 '23 00:01

bilabila


1 Answers

You can reselect last visual region typing gv

                        *gv* *v_gv* *reselect-Visual*
gv          Start Visual mode with the same area as the previous
            area and the same mode.
            In Visual mode the current and the previous Visual
            area are exchanged.
            After using "p" or "P" in Visual mode the text that
            was put will be selected.
like image 196
SergioAraujo Avatar answered Mar 11 '23 22:03

SergioAraujo