1, when the VI is opened by default command mode, to enter the input mode, you need to press A or I key.
Command mode:
: Wq Save and exit
: W only save does not eject
: Q Do not save exit
: q! Do not save forced exits
: wq! Save and Force exit
2 . Find
In command mode, enter/xxx, you can find the XXX
3, Fast switch line
In command mode, you can quickly switch to num lines by entering: num
4, set the display line number
In command mode, enter: Set Nu to display line numbers
Note: Setting does not display line numbers, Command mode input: Set Nonu
Set the permanent display line number, you need to modify the VI configuration file. Open the configuration file for VI ~/.VIMRC, where you can enter set Nu.
5, row Delete
Command mode, first move the cursor to the row to be deleted, enter DD
To delete contiguous rows, such as deleting contiguous 3 rows, use 3DD
6, line copy paste copy
Command mode, Nyy
To place the cursor on the first line of multiple rows when copying
7. Paste
Command mode, p
Paste to the next line in the row where the current cursor is located.
VIM Common Commands