Vim copy and paste

Source: Internet
Author: User
Tags gtk

Copy From Vim to system clipboard: "+ Y
Copy From system clipboard to VIM: "+ P or shitf + insert

In vim, the system clipboard is associated with the vim register +. Therefore, any copy and paste of register ++ directly affects the system clipboard.
Vim has 12 clipboard, which are 0, 1, 2,..., 9, A, ", +. You can use the: Reg command to view the content of each clipboard.

To copy Vim content to a clipboard, You need to exit the editing mode. after entering the normal mode, select the content to be copied, and then press "NY (note that there are quotation marks) to copy the content, n is the clipboard number (note that double quotation marks are followed by the clipboard number and then followed by Y). For example, to copy the content to clipboard a, select the content and press "ay, there are two points to note:

"No. Clipboard (temporary clipboard) is special. Press Y to copy it to the clipboard. Press P to paste the content in the clipboard;
+ The No. Clipboard is a system clipboard. After you copy the content to the clipboard with "+ Y", you can use Ctrl + V to paste it into other documents (such as Firefox and gedit). Similarly, to copy the content copied by pressing CTRL + C or right-click elsewhere to VIM, press "+ P in normal mode;

To paste the content in a clipboard of VIM, You need to exit the editing mode. In normal mode, press "NP, where N is the clipboard number, as described above, you can press "5 p to paste the content in the 5 th clipboard, or press" + P to paste the content in the global clipboard of the system.

Note: Here, only Vim. GTK or Vim. gnome can use the system global clipboard. The default Vim. Basic cannot see the + register. Install Vim. gnome and use apt-Get install vim-gnome. Then Vim automatically links to VIM. gnome.

Below are the basic commands for VIM copy and paste:
YY copies the entire row of the cursor. Or an uppercase y.
Copy 2yy or y2y. Sorry, please put it together!
Y ^ copy to the beginning of the line, or y0. Does not contain the character at which the cursor is located.
Y $ copy to the end of the row. Contains the character at which the cursor is located.
Copy a word from YW.
Copy two words (words) in the y2w format ).
Copy YG to the end of the file.
Copy y1g to the beginning of the file.
P lowercase P indicates that the cursor is appended to the lower case ).
P capital P indicates that the cursor is pasted to the Front (top ).

Copy a single character
Select normal mode (Press ESC)
Press V (specify the clipboard as "1 V quotation marks (no less) to enter the visual mode. Then you can move the direction key to select the text, and press y to copy the text,
If you want to start copying four characters from the cursor, you can press 4yl (after copying the cursor) ("14yl) (" 110yl followed by 10 characters ), 4 YH (before copying the cursor), then four characters are copied to the buffer zone,
Press it and you can use the p command (specify the clipboard as "1 V quotation marks must not be less) to paste it at will (1 refers to the bottom clipboard name)

Details: http://hi.baidu.com/xixer/blog/item/6030fccf20b7e530f8dc61ef.html

Copy From Vim to system clipboard: "+ Y
Copy From system clipboard to VIM: "+ P or shitf + insert

In vim, the system clipboard is associated with the vim register +. Therefore, any copy and paste of register ++ directly affects the system clipboard.
Vim has 12 clipboard, which are 0, 1, 2,..., 9, A, ", +. You can use the: Reg command to view the content of each clipboard.

To copy Vim content to a clipboard, You need to exit the editing mode. after entering the normal mode, select the content to be copied, and then press "NY (note that there are quotation marks) to copy the content, n is the clipboard number (note that double quotation marks are followed by the clipboard number and then followed by Y). For example, to copy the content to clipboard a, select the content and press "ay, there are two points to note:

"No. Clipboard (temporary clipboard) is special. Press Y to copy it to the clipboard. Press P to paste the content in the clipboard;
+ The No. Clipboard is a system clipboard. After you copy the content to the clipboard with "+ Y", you can use Ctrl + V to paste it into other documents (such as Firefox and gedit). Similarly, to copy the content copied by pressing CTRL + C or right-click elsewhere to VIM, press "+ P in normal mode;

To paste the content in a clipboard of VIM, You need to exit the editing mode. In normal mode, press "NP, where N is the clipboard number, as described above, you can press "5 p to paste the content in the 5 th clipboard, or press" + P to paste the content in the global clipboard of the system.

Note: Here, only Vim. GTK or Vim. gnome can use the system global clipboard. The default Vim. Basic cannot see the + register. Install Vim. gnome and use apt-Get install vim-gnome. Then Vim automatically links to VIM. gnome.

Below are the basic commands for VIM copy and paste:
YY copies the entire row of the cursor. Or an uppercase y.
Copy 2yy or y2y. Sorry, please put it together!
Y ^ copy to the beginning of the line, or y0. Does not contain the character at which the cursor is located.
Y $ copy to the end of the row. Contains the character at which the cursor is located.
Copy a word from YW.
Copy two words (words) in the y2w format ).
Copy YG to the end of the file.
Copy y1g to the beginning of the file.
P lowercase P indicates that the cursor is appended to the lower case ).
P capital P indicates that the cursor is pasted to the Front (top ).

Copy a single character
Select normal mode (Press ESC)
Press V (specify the clipboard as "1 V quotation marks (no less) to enter the visual mode. Then you can move the direction key to select the text, and press y to copy the text,
If you want to start copying four characters from the cursor, you can press 4yl (after copying the cursor) ("14yl) (" 110yl followed by 10 characters ), 4 YH (before copying the cursor), then four characters are copied to the buffer zone,
Press it and you can use the p command (specify the clipboard as "1 V quotation marks must not be less) to paste it at will (1 refers to the bottom clipboard name)

Details: http://hi.baidu.com/xixer/blog/item/6030fccf20b7e530f8dc61ef.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.