Vi-vim Basic Operation

Source: Internet
Author: User

Vi-vim Editor: Full screen editor, modal editor


Vim mode:
Edit mode (Command mode)
        Input mode
        Last-line mode (bottom-row mode)

Mode conversion:
        Edit mode--Input mode:
                I: Enter in front of the character where the current cursor is located
                I: Input at the beginning of the line where the current cursor is located
                A: Enter after the character of the current cursor
                A: Insert at the last name of the line where the current cursor is located
                O: Enter the next line in the row where the current cursor is located
                O: Enter on the previous line of the row where the cursor is currently located
        Input mode--edit mode:
                Esc
        Edit mode--and last-line mode:
                :
        Last-line mode--edit mode
                ESC[ESC]



Open File
        Vim/path/to/file
        Vim +n/path/to/file: Open the file while the cursor moves to the beginning of the nth line
        Vim +/path/to/file: Open the file while the cursor moves to the beginning of the end of the file line
        Vim +/pattern/path/to/file: Open the file while the cursor moves to the beginning of the 1th match pattern


Close File
        1. Closing the file in the last line mode
                : Q exit
                : q! Do not save forced exits
                : W Save
                : w! Force save (only administrators have this permission for read-only files)
                : Wq Save and exit
                : X Save and exit
        2. Close the file in edit mode
                ZZ Save exit

Move cursor
        1. Move the cursor character by word
                H: Move the cursor one character to the left
                L: Move the cursor one character to the right
                J: Move the cursor down one line
                K: Move the cursor up one line
        #h上面的命令前面都可以加上数字, the entered numeric characters are moved.

        2. Move in Word units
                W: Move to the beginning of the next word
                E: Moves to the ending of the current word or the next word, and jumps to the current word ending if the cursor is not at the ending of the current word
                B: Move to the beginning of the current word or the previous word
        #w: Moving a number of units

        3. In-line jump
                0: The absolute beginning
                ^: first non-whitespace character at the beginning of a line
                $: absolute end of line

        4. Jump between rows
                #G: Jump To Line #
                G: Jump to the last line

Flip Screen operation
        1. Ctrl + F: Flip one screen forward
        2. Ctrl + B: Turn back one screen
        3. Ctrl + D: Flip forward half screen
        4. Ctrl + u: Turn back half screen

Edit command:
        1. Delete a single character
                X: Delete a single character at the cursor location
                #x: Remove the # characters that are backward at the cursor
        2. Delete multiple characters
                d command and Jump command combination can choose how much to delete
                DE, DB, DW
                DD: Delete a row
                #dd: Delete # lines

In the last line mode, you can use:
        Startadd,endaddd
        .: Indicates when the forward
        $: Top row
        +#: Down # line


Paste command:
        P: If you delete or copy the entire line, paste it below the line where the cursor is located, and paste is after the character of the cursor if the copied or deleted content is not a whole line
        P: If you delete or copy to an entire row, paste to the top of the line where the cursor is located, and paste is preceded by the character of the cursor if the copied or deleted content is not a whole line

Copy command:
        Y: Usage with d command

Delete content first, then convert to input mode--Modify
        C: Usage with d command

Replace:
        R:

To undo an edit operation:
        U: Undo the previous operation
                Can be revoked multiple times continuously
        #u: Undo Recent # Operations directly

Undo Last Action:
        Ctrl + R

Repeat the previous edit operation:
        .

Visualization mode
        V: Select by character
        V: Select by rectangle

Find
        /pattern: Looking forward
        ? pattern: Looking backwards

Find and replace
        Using the S command in the last-line mode
        S/pattern/string/g


Vi-vim Basic Operation

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.