How to exit vim

Rob

Administrator
Staff member
Joined
Oct 27, 2011
Messages
1,161
Reaction score
2,107
Credits
3,161
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>
 


JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,704
Reaction score
2,471
Credits
13,677
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
MALIBAL Linux Laptops

Linux Laptops Custom Built for You
MALIBAL is an innovative computer manufacturer that produces high-performance, custom laptops for Linux.

For more info, visit: https://www.malibal.com

Members online

No members online now.

Latest posts

Top