Vim Cut Copy

Source: Internet
Author: User




Ubuntu,vim The default external registers are +


Copy the contents of vim to the system, select the content, and then "+y, you can copy it to the outside."
Copy the contents of the system to vim, select a location, and then "+p, you can copy it into vim."





The Clipboard function in Vim is very powerful, it places the copied or cut content in a place called registers, and enters in vim command mode

: Reg
You can view the contents of the register as follows:

There are many registers in





Vim, as shown in the figure above, followed by the contents of the register, for example:


0   Http://news.replays.net//news/web Down. The
  This line means that the contents of register "0 (commonly called Register 0) are: Http://news.replays.net//news/webdown


When you want to get the contents of the register to paste it somewhere, Typically enter a register number (such as "0") in command mode, then enter the Paste command (p), for example, if I am going to paste the contents of "0" behind the cursor, type "0p" in command mode (press and hold the SHIFT key, which means that the key to this operation is SHIFT +). > 0--> P).


 


What you need to note is that Vim's clipboard is unique, meaning that the contents of its clipboard are only in Vim when you paste it, and that only one register 8 is shared with the operating system ( Windwos under the 8,unix series operating system may have a difference), that is to say this clipboard listen to content you may be in other applications like Word Ctrl + V paste, and you in Word CTRL + C content in vim through "8p can be pasted down."


In addition, the contents of the Reg in Vim will remain in place for a long time, and will still be present at the next system startup, which is to put the content in the appropriate file.


 


Below is a simple command to select, copy, Cut, and paste in vim:


y, y: Copy the line at the current cursor
Nyy, NY: Copy n lines at and below the current cursor br> DD: Cut the line at the current cursor
NDD: cut n rows at the current cursor and below
P: Paste the content below the current cursor.
P: Pastes the contents above the current cursor.
V: Start the selection, then press HJKL several arrow keys to start the selection;

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.