Multi-row replication in unbunt Vim

Source: Internet
Author: User

I am not disgusted with the Linux system, but I am disgusted with complicated command operations. I feel that as a programmer, I should focus on the Code architecture and writing, rather than memorizing these commands.

I wrote this article because I was configuring the source of an Ubuntu server some time ago. However, for the command line-only interface, I had to take a good look at these commands. (There may be a lot of cases. Isn't the blogger having file ing ?, Well, I cannot set up a samba on a server to configure a source file, right ?, So remember some basic commands)

For example, if you want to copy data from 1st rows to 5th rows

Move the cursor to any position in line 5th and enter Ma
Move the cursor to any position in row 1st and enter y 'a (this must be put in single quotation marks, otherwise it will enter the "insert" status.
Move the cursor to the row to be copied, enter P, and copy the input capital P before the row

Or

First move the cursor to the second line, and then D4 (a total of 1 ~ is copied here ~ Five rows. The trick is to use the DELETE command. In fact, here is to delete 1 ~ Five rows. After the deletion is complete, you must use the U command to cancel the deletion. However, this 1 ~ Five rows, so P can be used for copying)
P
Move the cursor to the position to be pasted.
P

Or

Move the cursor to 9th rows
Shift v
Move the cursor to the second line.
CTRL C
Move the cursor to the second line.
P

Or

The nyy command is used to copy n rows starting from the row where the cursor is located. Generally, there are many numbers that are very intuitive within five rows.

I prefer the third method, which is simple and intuitive, and uses Ctrl + C, a command that is almost synonymous with replication.
Note:
Do not copy multiple rows at the same time, but only recognize the first time. My method is to use YY to copy the same (that is, cancel copying multiple rows );
Query the row number. In non-editable mode, enter: set number.

Vim insert other file content
Insert R/path/filename in command mode

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.