How To Exit Vim

How to exit Vim

The Canonical way

The “Abort! Abort!” way

The “Sudo” way

The power user’s way

The fallback way

The UNIX way

For some reason or other, if you are stuck in Vim, there are many ways to exit. Here are but a few.

However, first we need to cover some Vim history. The first editor to grace UNIX was ed. This is what JEDI is a clone of. Next in line is EX. EX stands for EXtended. More on this later. After EX, people had enough terminal cycles to display a file. This caused the birth of Vi. Vi stands for VIsual. Vim is an extension of Vi. Whenever you press : in Vim, you are actually invoking an EX command. Now, on to the commands!

Before entering these commands, press ESC

The canonical way

:wq

to save and quit.

The “Abort! Abort!” way:

:q!

To save without quitting

The “Sudo” way:

:wq!

To force a save and quit

The power user’s way:

ZZ

This is the same as :wq

The fallback way:

ZQ

This is the same as :q!

The UNIX way:

^Z
killall vim

I now hope will never post “how to quit vim” on Stack Overflow again

One more joke

Written on March 18, 2020