Just a question about copy/paste workflow in gVim.
Right now I'm working on a document. I want to select some lines of code and copy and paste. I'm using gVim (Windows).
If I use Control + C and Control + V, gVim takes sometimes 2, 3 seconds to paste...
The other way is using, Shift + v (right, now I'm in visual mode), then I keep the Shift key pressed and drag my selection with the mouse. Now I can copy with 'y' or 'c' and paste with 'p'. This is faster, but I have to keep the Shift key pressed.
Is there a way to use the mouse to select text in visual mode without keeping the Shift key pressed? I want to use y/d/p instead of slow Control + c and Control + v. Is there a better workflow or setup that I should try?
Thanks,
[]'s
Mateus
Copy Current Line in VIM To copy the current line (line in which the cursor is placed), simply press double lower y ( yy ) or single upper case y (Y).
You can copy a block of text by pressing Ctrl-v (or Ctrl-q if you use Ctrl-v for paste), then moving the cursor to select, and pressing y to yank.
Press the “Esc” key and tap “I” to open the “Insert” mode of the Vim editor. The “yank” or “y” command is used to copy the selected text.
Press v to select characters, or uppercase V to select whole lines, or Ctrl-v to select rectangular blocks (use Ctrl-q if Ctrl-v is mapped to paste). Move the cursor to the end of what you want to cut. Press d to cut (or y to copy). Move to where you would like to paste.
Stay away from using CTRL-C/V and your mouse in vim
, or at least until you're familiar with vim
's way of text handling.
--
SHIFT-V to enter visual line mode
Press 3j
to go down 3 lines, or press j
3 times
y
to yank/copy, x
to cut, p
to paste after cursor, P
to paste before cursor.
Using hjkl will improve your workflow greatly as you don't have to move your hands from the typing position to the arrows and the mouse.
There are a couple of ways to yank multiple lines without entering visual mode. One of which is to type <action><number><direction>
. For example, y3j
means to yank from your current row to 3 rows down.
If you want to yank the entire paragraph or sentence you're in, type yip
(yank IN paragraph) or yis
(yank IN sentence) respectively. You can also do yi"
(yank IN "
) or ya"
(yank AROUND "
) to yank everything that's surrounded by "
on your current position.
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