Exiting Vim

Parameters

ParameterDetails
:Enter command-line mode
wWrite
qQuit
aAll
!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 forcefully (with save)

:wq!

Exit forcefully (without save)

:q!

ZQ

Exit forcefully from all opened windows (without save)

:qa!

Exit with save

:wq

ZZ

Exit without save

:q!

if multiple files are opened

:wqall

Exiting multiple files with saving contents

:qall!

Exiting multiple files without saving contents