In Linux, the Vim editor is the system's own text editor, but to modify a text file, it is not like Windows, more novice, into the VI editor, can not exit so that the forced shutdown, in fact, this vim (vi) is very simple.
1. Enter the VIM editor
Vim Editor, you can create a new file or modify a file, the command is: vim/usr/local/con.cfg
If this file is not previously available, then new, there is a prompt for the new file below, and no prompt if the file already exists.
After entering the editor, we first press "I", that is, switch to the "insert" state. You can edit the content by moving the cursor or space, backspace, and carriage return to and from the left and right, and Windows is the same.
2. Ways and differences of exiting VIM editor
When the text editing is finished, you usually need to exit the editor and exit the editor in 4 different situations: Save exit, exit normally, do not save exit, and force exit.
① Save exit
When we edit or modify the contents of the file, of course we have to save and exit and then the next step. At this point, we have to press the "ESC" in the upper left corner of the keyboard to notice it? The insertion state in the lower left corner is missing, then we enter "colon", i.e. ":" (without double quotes), a colon appears below, wait for the input command, enter "Wq", the function is as follows:
W:write, writing
Q:quit, exit
Then return to the store and exit. In fact, there are two ways to save an exit:
A: In the last input command, the direct input "X", is also the same, that is: X=wq.
B: The quickest way: After pressing ESC, press SHIFT+ZZ directly or switch to uppercase mode by ZZ, you can save the exit, that is, two uppercase Z.
We can view its contents with the View command cat: Cat/usr/local/con.cfg.
② Normal exit
The normal exit has a precondition: The Open text file has not been changed in the content. Press ESC and then enter "Colon", and enter "Q" Directly when you enter the command.
③ Do not save exit
Many times open the file or modify some places, only to find the wrong, need not save exit. Press ESC, enter "Colon", and enter "q!" directly when you enter the command.
④ forced exit
Less common operations, first press ESC, then "Colon", enter the command, directly enter "!", after exiting, there will be a hint!
Note: Linux commands are lowercase!
How to get out of the Vim editor in a Linux system