[Vim] common basic Vim operations

Source: Internet
Author: User
1. Navigate to 1.1. view the row number

    : Set numberShow row number

    :. =Display the current row number at the bottom

    : =Display the total line number at the bottom

 

1.2. move the cursor

    0^Move the cursor to the beginning of the current row

    $Move the cursor to the end of the current row

    WMove to the start of the next word

    BMove to the beginning of the previous word

    : 0 1gGgMove to first line

    :NNGMove to row n

    : $GMove to the last row

 

2. copy and paste 2.1. Select multi-row copy based on the row number

    : 1, 10t20Copy the contents of rows 1st to 10 and paste them to the end of rows 20th.

    : 1, 10 t.Copy the contents of rows 1st to 10 and paste them to the end of the current row.

    : 1, 10yCopy 1st to 10 rows to the clipboard.

 

2.2. Copy a single row or multiple consecutive rows

    YYCopy current row

    NYYCopy the current row and its subsequent N-1 rows.

    PPaste the content in the clipboard in the current row.

 

3. Search 3.1. query string

    /StringSearch for the string in the forward direction.

    ?StringReturns the string.

    NSearch for the next one in the current order.

    NSearch for the next one in reverse order.

 

4. Edit 4.1. Undo and restore

    UCancel operation

    <Ctrl> rRestore operation

 

4.2. Insert text

    IInsert before cursor

    IInsert at the beginning of the current row

    AInsert after cursor

    AInsert at the end of the current row

    OInsert the next row

    OInsert the last row

 

4.3. edit text

    RReplace a single character covered by the cursor

    RConsecutive replacement of a single character covered by the cursor

    CWReplace the word behind the cursor

    CNWAfter replacing the cursorNWords

    CCCClear current row

    NCCCNCClear currentNLine

 

4.4. delete text

    XDelete a single character overwritten by the cursor

    NXDelete n characters after the cursor

    DWDelete the word after the cursor

    DNWDelete n words after the cursor

    DDelete the content behind the cursor.

    DdDelete current row

    NDdDNDDelete n rows after the current row

:X,YDDelete row X to row y

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.