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