Use VI Editor to delete copy or move multiple lines of text under Linux

Source: Internet
Author: User

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

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.