VIM copy and paste

Source: Internet
Author: User


Content: After using vim for so long, I never know how to use the system clipboard in vim. Generally, to copy a piece of code on the internet, open the file in gedit and paste it in the middle and close it, it's really bad to use vim to open the editor. Someone on the last Forum asked how to use the system clipboard in vim. There were a lot of replies, but there were several pages of replies that didn't solve the problem, today, I can't stand it anymore. I tried to find a solution on the Internet. I accidentally found it and posted it for sharing. Www.2cto.com if you only want to use the system clipboard, press Shift + Inset (paste) in the input mode. Next, let's talk about the basic knowledge of vim clipboard. If you are interested, please take a look, it should be rewarding. In the vim Help document, the clipboard-related content is as follows: vim has 12 clipboard boards, which are 0, 1, 2, and ,..., 9, a, ", +; Use the: reg command to view the content of each clipboard. In vim, simply copy y to the "(double quotation marks) clipboard. Also, p is used to paste the content in this clipboard. Copy the vim content to a clipboard, you need to exit the edit mode. after entering the normal mode, select the content to be copied, and then press "Ny (with quotation marks) to complete the copy, 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. + NO. Clipboard is a system clipboard, copy the content to the clipboard with "+ y" and press 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, 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 clipboard, you can also 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 www.2cto.com is the basic command for vim copy and paste: yy copy 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 to the normal mode (Press ESC on the line) and press v (specify the clipboard as "1 v quotation marks cannot be less) to enter the visual mode, then you can move the direction key to select the text, then press y to complete the copy. If you want to start copying four characters from the cursor, you can press 4yl (after copying the cursor) ("14yl) ("10 characters After 110yl), 4yh (before the cursor is copied), 4 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)

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.