How to exit vim

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
1,222
Reaction score
2,286
Credits
3,574
This question comes up a LOT with users experimenting with different editors.

To exit vim, hit ESC to get out of insert mode, then type the following, including the colon

Quit, saving changes:
Code:
:wq<ENTER>

Quit, NOT saving changes:
Code:
:q!<ENTER>
 


Additionally, if you have multiple files open in different buffers/tabs:
To save all files and quit you can use:
Code:
:xa<ENTER>
or
Code:
:wqa<ENTER>

The differences between the two options are:
:xa - will only save buffers/files that have changes in them before quitting. So if a file does not have any changes, it will simply be closed.
:wqa - will save all buffers before quitting, regardless of whether there were any changes.


To close all files/buffers/tabs without saving:
Code:
:qa!<ENTER>
or
Code:
:xa!<ENTER>
Both of these commands are equivalent.
 
  • Like
Reactions: Rob


Top