VI and Vim Editor and its shortcut keys
1. The difference between VI and VIM
They are multi-mode editor, the difference is that Vim is the upgrade version of VI, it is not only compatible with all VI directives, but also some new features inside.
These advantages of vim are mainly reflected in the following aspects:
A, multilevel undo
We know in VI, press u can only undo the last command, and in Vim can be unlimited undo.
b, Ease of use
VI can only run on Unix, and vim not only runs on Unix,windows, Mac and other multi-operating platforms.
C, Syntax highlighting
Vim can use different colors to highlight your code.
D, visual operation
This means that VIM can be run not only at the terminal, but also in X window, Mac OS, Windows.
E, fully compatible with VI
In some cases, you can use Vim as VI.
VI and VIM are all editors in Linux, the difference is that vim is more advanced, can be regarded as the upgrade version of VI. VI is used for text editing, but Vim is more suitable for coding.
2, VI mode
VI has 3 modes: command-line mode (commands mode/general mode), text input mode (input mode/edit mode), and end-line mode (last lines mode/Instruction-column command mode).
Command-line mode (commands mode/general mode)
At any time, no matter what mode the user is in, just click the "ESC" key, you can get VI into the command line mode; We enter the Launch VI command under the shell environment (prompt $), which is also in this mode when you enter the editor.
In this mode, users can enter a variety of legal VI commands for managing their own documents. Any character entered from the keyboard is interpreted as an edit command, and if the input character is a valid VI command, VI completes the corresponding action after accepting the user command. Note, however, that the commands you enter are not displayed on the screen. If the input character is not a legal command of VI, VI will ring the alarm.
Text input mode (input mode/edit mode)
In command mode, enter the Insert command I (insert), attach command A (append), open command O, modify command C (change), replace command R, or replace command s to enter the text input mode. In this mode, any characters entered by the user are saved by VI as the contents of the file and displayed on the screen. In the text input process, if you want to return to the command mode, press the "ESC" key.
Final line mode (last lines mode/command mode)
The last line mode is also known as ex escape mode.
The functions of the VI and ex editors are the same, the main difference being the user interface. In VI, commands are usually a single key, such as I, A, O, etc., whereas in ex, the command is the body line that ends with a hit return. VI has a dedicated "escape" command to access many of the line-oriented ex commands.
In command mode, the user presses the ":" Key to enter the last row mode, at which time VI displays a ":" As a prompt in the final row of the display window (usually the last line of the screen), waiting for the user to enter a command. Most file management commands are executed in this mode (such as writing the contents of the edit buffer to a file medium). After the last command is executed, VI automatically returns to the command mode.
3. Vim mode
There are 4 modes of VIM:
Normal Mode (Normal-mode)
Insert mode (Insert-mode)
Command mode (Command-mode)
Visual Mode (Visual-mode)
Normal mode
The default is in normal mode when Vim is started. No matter what mode you are in, pressing the <Esc> button (sometimes pressing twice) will enter normal mode.
Insert mode
Pressing I, I, a, a etc in normal mode will enter insert mode.
Now just remember to press the I key to insert mode. In insert mode, the corresponding character is written when the key is clicked.
Command mode
In normal mode, press the: (English colon) key to enter command mode.
In command mode, you can perform some input and execute some of the instructions provided by VIM or plug-ins, just like in the shell. These directives include setting up the environment, file operations, invoking a feature, and so on.
Common commands are: Q (exit), q! (Forced exit), W (save), Wq (Save and exit).
Visual mode
Press V, V, <ctrl>+v in normal mode to enter the visual mode.
Operation in the visual mode is a bit like taking the mouse to operate, select text when there is a mouse to choose the visual sense, sometimes it is very convenient.
4, VI and Vim shortcut keys
Reference Source:
69544064
Https://www.linuxidc.com/Linux/2016-06/132019.htm
Linux Learning 13-vi and Vim editor and its shortcut keys