Exiting Vim
Parameters#
Parameter | Details |
---|---|
: |
Enter command-line mode |
w |
Write |
q |
Quit |
a |
All |
! |
Override |
Remarks#
Command-line mode is entered through normal mode. You will know you are in command-line mode when there is a :
in the bottom left corner of your terminal window.
Normal mode is the default mode of vi/vim and can be switched to by pressing the ESC.
Vi/Vim have built-in checks to prevent unsaved work from being lost and other useful features. To bypass these checks, use the override !
in your command.
In Vi/Vim it is possible to have more than one file displayed (in different windows) at the same time. Use a
to close all the opened windows.
Exit with save
:wq
ZZ
Exit without save
:q!
Exit forcefully (without save)
:q!
ZQ
Exit forcefully (with save)
:wq!
Exit forcefully from all opened windows (without save)
:qa!
if multiple files are opened
:wqall
Exiting multiple files with saving contents
:qall!
Exiting multiple files without saving contents