Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy selected lines to clipboard in vim

Tags:

vim

How to copy selected lines to clipboard in vim. I know how to do it for all text files, but I want to do in for selected lines. Thanks!

like image 432
ashim Avatar asked Feb 06 '12 19:02

ashim


People also ask

How do I copy a line in vi editor to clipboard?

Press the ESC key to be sure you are in vi Command mode. Place the cursor on the line you wish to copy. Type yy to copy the line.

How do I copy a specific line in Vim?

Press y to copy, or d to cut the selection. Move the cursor to the location where you want to paste the contents. Press P to paste the contents before the cursor, or p to paste it after the cursor.

How do you copy and paste multiple lines in Vim?

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.


1 Answers

SHIFTV puts you in select lines mode. Then "*y yanks the currently selected lines to the * register which is the clipboard. There are quite a few different registers, for different purposes. See the section on selection and drop registers for details on the differences between * and + registers on Windows and Linux.

like image 79
Spencer Rathbun Avatar answered Sep 25 '22 21:09

Spencer Rathbun