Practical VI skills

Source: Internet
Author: User

How to Use VI to copy 5th rows to 10th rows and paste them after 12th rows:

 

Method 1:
Place the cursor on the fifth line,
Input: y6y
Place the cursor in Row 3,
Input: P

Method 2:
Input in Command Line Mode
: 5, 10 co 12

Method 3:
Generally
Move to the fifth row D6 first
P
Move to 12 rows
P

In addition, you can use tags to replace multiple rows or copy a large number of rows:

Move the cursor to the starting line and enter Ma
Move the cursor to the end line and enter MB
Move cursor to paste line, input MC
Then: 'a, 'B co' C

 

If you save a large amount of code to one file and then open the code to be copied in another file:

In File 1:
Move the cursor to the starting line and enter Ma
Move the cursor to the end line and enter MB
Then: 'a, 'B W filename
In file 2:
Move the cursor to the row to be assigned a value. input:

: R filename

VI provides commands for text movement and copying. You can use these commands to conveniently copy characters, text, lines, and text blocks.
The related commands are as follows:
YY copies the current row to the buffer
YW copies the current word to the buffer zone
Y1 copies a character at the cursor to the buffer
P paste the buffer information behind the cursor

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.