introduce

All Linux systems come with a vi text editor. Vim has the ability of program editing, which can be regarded as an enhanced version of VI. It can actively identify the correctness of syntax by font color, which is convenient for program design. Code completion, compilation and error jump and other convenient programming functions are particularly rich, widely used in programmers.

Three common patterns

  • Open a file in Vim to enter normal mode (this is the default mode). In this mode, you can use the “Up, Down, Left, Right” buttons to move the cursor, you can use “Delete Character” or “Delete Whole Line” to work with file contents, and you can use “Copy and Paste” to work with your file data. Shortcuts are available in normal mode.
  • Insert mode/edit mode

    Press theI (insert), I, O, O, A, A, R, RWait for any letter to enter edit mode, usually pressiCan.
  • Command-line mode in this mode, can provide you with relevant instructions, complete read, save, replace, leave Vim, display line number and other actions are done in this mode!

The mode switch

shortcuts

Cursor position movement

  • Position the cursor to the beginning or end of the file

    GG header G(Shift + G) tail
  • The beginning or end of a line

    ^ Line beginning $line end
  • Moves to the specified row

    :n move number n row

Delete or cut

  • Delete specified character

    X Deletes the character at the cursor position nx Deletes the N characters # from the cursor position or use the Backspace key in edit mode
  • Delete the entire line

    Dd deletes a single row and NDD deletes n rows

    ddBoth delete and cut, the deleted content is already in the clipboard

  • Cut using dd after deletion

    Paste after the cursor p (large) paste before the cursor
  • Delete from the cursor line to end of file

    DG D is Delete, G End

copy

Yy copies a single row and nyy copies n rows

I can copy it and still paste it,
por
P (large)

undo

Ctrl + R Undo: Undo until the file is open

replace

R replaces the cursor at the character R into replace mode, the arrow key movement can replace any position of the character

To find the

/ Look down the line from the cursor? Look up from the line where the cursor is

N: the next N: the last