First, delete multiple lines
Single-row deletion,: 1 (line number to be deleted) d
Multi-line Delete,: 1,10d
Dd
Delete the cursor in the row
Ndd
Delete n rows starting at the current line
Dw
Deletes a character starting with the current character
Ndw
Deletes n characters starting with the current character
d$, D
Deletes a line of characters starting with the current character
D
Delete to the beginning of the next sentence
D
Delete to the beginning of the next paragraph
D Enter
Delete 2 rows
Second, duplicate multiple lines
Task: Copy data from line 9th to line 15th to line 16th
Method 1: (Highly recommended)
: 9,15 copy 16 or: 9,15 Co 16
This can include:
: 9,15 move 16 or: 9,15 m 16 moves the text content of line 9th through 15th to the back of line 16th
Method 2:
Cursor moves to the end line, enter MA
Move the cursor to the start line, enter Y ' a
Move the cursor to the line you want to copy, enter P, and then enter uppercase p before the line is copied.
Method 3:
Move the cursor to line 9th SHIFT + V
Then move the cursor to line 15th CTRL + C
And then the cursor dies to line 16th p
Method 4:
Move the cursor to the start line, enter the MA
Move the cursor to the end line, enter MB
Move cursor to paste line, enter MC
Then enter: ' A, ' B, CO ' C change the Co to M is cut
To delete multiple rows, enter: ' A, ' B de
VI Set auto indent: Set smartindent
VI Settings Display line numbers: Set number or set Nu
Use VI Editor to delete copy or move multiple lines of text under Linux