All Linux systems come with VI text editor.
VIM has the ability of program editing, which can be seen as an enhanced version of VI. it can actively distinguish 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, which are widely used in programmers.
Three common modes
- Normal mode / general mode
Open a file with vim and go directly to 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 process the file content. You can also use copy and paste to process your file data. Shortcut keys are available in normal mode.
- Insert mode / edit mode
i（insert）, I, o, O, a, A, r, RWait for any letter before entering edit mode. Generally speaking, press
- Command line mode
In this mode, you can provide relevant instructions to complete the actions of reading, saving, replacing, leaving VIM, displaying line number, etc!
Cursor positioning movement
The cursor is positioned at the beginning or end of the file
GG file header G (Shift + G) end of file
Beginning or end of line
^The beginning of the line $end of line
Move to specified line
: nmobile number line n
Delete or cut
Delete specified character
X delete the character at the cursor position Nx removes n characters from the position of the cursor #Or use the backspace key to delete in edit mode
Delete entire line
DD delete single line NDD delete n rows
ddIt’s both deleting and cutting. The deleted content has been put into the cutting board
P paste to the back of the cursor P (large) pastes in front of the cursor
Delete from the cursor line to the end of the file
DG, D is delete, G is the end of the file
YY copy single line NYY copy n rows
You can still paste after copying,
U undo, which can be undone until the file is opened CTRL + R reverses the revocation and can return to the last operation state
R replaces the character at the cursor R enter replace mode, direction key movement can replace any position character
/Look down from the line where the cursor is ? Look up from the line where the cursor is
n: Next N: Previous