linux vim save and exit command

linux vim save and exit command: first press ESC to enter Command mode, then enter ":wq", press Enter to save and exit.
Other save/exit commands of vi:
:w save;
:w filename save as filename;
:wq! save and force quit;
:wq! filename Note: force quit after saving with filename;
:q! force quit;
: x save and exit (save only if file changes)

 

You can also install the vim editor:
enter the command in the terminal:

sudo apt-get update
sudo apt-get install vim


Create a file:
cd ~
vim word.txt

Open the vim editor through the above command. (It should be noted that when using the vim editor to create a file, no matter whether it has the extension .txt or not, it will generate a text file.)

Enter editing mode:
Press the letter i or a on the keyboard to start editing!

Exit editing mode:
vim save and exit Command 1: Press the esc key, input ":wq" 3 English characters, and then press the Enter key, which means to save the file and exit.
vim save and exit command 2: Press the esc key, enter two English characters ":q", and then press the Enter key, which means exit without saving. (If there is no modification in this edit, you can exit smoothly; otherwise, the vim editor will not allow you to exit. At this time, if you want to exit without saving, you must use the following method 3) vim save and exit Command 3
: Press the esc key, enter ":q!" 3 English characters, and then press the Enter key, which means to quit without saving.

Guess you like

Origin blog.csdn.net/yetaodiao/article/details/128458280
Recommended