How to quit vi, vim, emacs, nano, joe, jed, ed, ex and other command line / terminal editors

Someone once said that if you want a random string, put a newbie in front of a Unix editor and ask them to quit. How many times have you said "Hey, let's try this editor and then 5 minutes later you find yourself running kill -9 5964 in another terminal. For some, this experience alone is a big turn off from Unix and they never come back.[1]

This page assumes that you would like to quit the editor WITHOUT saving the file. If you've come this far, you may have already botched up an important file and would rather not save your work until you have a chance to become more familiar with the editor on a less important file.

vi, vim, nvi, elvis

vi and its derivatives are what are called modal editors. Meaning that you have to use a key to switch them between command mode and edit mode. The quickest way to escape to command mode and quit without saving is:


Emacs or jmacs

emacs has hotkeys that can be pressed at nearly any time. To quit emacs without saving just press:

[Ctrl] + x
[Ctrl] + c

Nano and Pico

nano and pico are modeless editors which are probably the most familiar text mode editors for beginners because their on screen help that is always visible at the bottom.

[Ctrl] + x

joe, jstar

The joe editor is also a modeless editor meant to emulate the feel of the older wordstar and Turbo C editors.

[Ctrl] + k
[Ctrl] + c


jed actually uses emacs keybindings for the most part so the method of quiting is the same:

[Ctrl] + x
[Ctrl] + c


ex is a line mode editor that is based on vim. Its basically like being in vim command mode. So you quit the same way but without pressing escape.



ed is another line mode editor that is based on sed. Actually, its the other way around. sed is based on ed. but anyways.



ne is the "Nice Editor". Its rare but some people may encounter it. Perhaps you meant to type something else and ended up inside this editor.

[Ctrl] + q
select "quit now"

[1] Maybe that's for the best. If they give up so easily, then what an editor doesn't do, the tar command will finish later.

Created: 2013-11-25

blog comments powered by Disqus