当前位置:网站首页>VIM editor knowledge summary

VIM editor knowledge summary

2022-07-04 22:58:00 Song Xiaoyu

1. Three models

Input vi/vim <filename> You can enter a file ( Whether this file exists or not ) Command mode of , Input wq Wait for the baseline command to exit the file command mode .

Schematic diagram of working mode

  • Command mode

    Input i o a Wait to enter the input mode ;

    Input : You can enter the baseline command mode

  • The input mode

    except Esc Out of bond , Other keys are input ;

    Press Esc Key to exit the input mode , Enter command mode .

  • last line node

    Operation command with enter End the baseline command mode ;

    Press Esc Key to exit the input mode , Enter command mode .

2. Introduction to commands in different modes

2.1 Command mode

  • Move the cursor

    0 Numbers 0, Move to the first character of this line

    $ Move to the last character of this line

    G Move to the last line of this file

    nG n Integers , Move to this file n That's ok

    gg Move to the first line of this file , amount to 1G

    n<Enter> n Integers , Subject to the current behavior , Move down the n That's ok

  • Search for replacement *

    /word Search under the cursor for a name word String

    n Continue to find the content of the search string in the previous step

    N Continue to look up the search string content of the previous step

  • Copy 、 Paste and delete **

    x,X x Indicates that the cursor is deleted The last character ;X Indicates that the cursor is deleted Previous character

    dd Delete the current line of the cursor

    ndd n Integers , Delete the downward position of the cursor n That's ok ( Start with the line where the cursor is )

    yy Copy the current line of the cursor

    nyy n Integers , Copy cursor down n That's ok ( Start with the line where the cursor is )

    p,P p To paste the copied data to the next line under the cursor , P Is pasted onto the upper line of the cursor

    u Recover the previous action

    Ctrl+r Redo the previous action

    . decimal point , Repeat the previous action

2.2 Relevant buttons for switching from command mode to input mode

  • Enter input mode

    i Enter... From the current cursor

    I Enter

    a Start at the next character where the current cursor is

    A Enter at the last character of the current line

    o Lowercase letters o, At the current cursor Enter a new line at the next line

    O Capital o, Enter a new line on the previous line where the current cursor is

  • Enter substitution mode

    r Replace a character where the cursor is

    R Always replace the text where the cursor is , Until pressed ESC until

  • Exit input mode

    Esc Exit input mode , Go back to command mode

2.3 Switch the command mode to the bottom line command mode

  • Commands such as saving and exiting files

    :w Save changes

    :q sign out vi Edit mode

    :wq Save the changes and exit vi Edit mode

    ZZ Capital letters z, Equate to :wq, Save the changes and exit vi Edit mode

    :<>! Add... After the order ! Number , Indicates a forced operation

  • Line number display operation

    :set nu According to the line Numbers

    :set nonu Cancel the display line number

Reference documents

https://www.runoob.com/linux/linux-vim.html

原网站

版权声明
本文为[Song Xiaoyu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/185/202207042230009742.html