Copy, cut, delete, and undo VI/Vim

Source: Internet
Author: User
In VI/vim, copy and use "Y" and delete with "D". What about the clipboard? The clipboard is deleted and then pasted. The original deletion is not a real deletion, but a buffer.

Copy
1. In "YY" editing mode, copy the content of the row where the cursor is located.
2. In "nyy" editing mode, copy a total of N rows starting from the row where the cursor is located.
3. ": N1, n2y" in command line mode, copy the content of all rows starting with N1.

Delete
1. "DD" deletes the content of the row where the cursor is located.
2. "NDD" deletes n rows starting from the row where the cursor is located.
3. ": N1, n2d" deletes the content of all rows ending with N2.

Clipboard
After a delete operation is executed, press "p" to paste the cut content under the row where the cursor is located.

Others
1. ": n1con2" copy the content of Row-marked N1 to the bottom of Row-marked N2.
2. ": N1, n2con3" copies the content between the row-marked N1 and N2 to the row-marked N3.
3. ": R file name" copies all the content of the file to the current file and inserts it under the row where the cursor is located.

Undo
1. "U" undo the previous operation
2. ": E! "Return to the state when the file is loaded (the premise is that the file has not changed outside VI after the file is loaded), the essence is to load the file from the hard disk. This is useful when editing files in multiple ways.

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.