Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recover from messy situations in Emacs?

Tags:

emacs

I am just starting out in in Emacs. Sometimes I'll be experimenting with something and when I'm finished experimenting, I want to just go back to the buffer I was editing, but I don't know how. Worse, sometimes I hit a key by accident and don't even know what I hit! In Vim I can just hit ESC to recover; is there any similar way to recover in Emacs?

EDIT: I am using the command line (non-GUI) Emacs.

like image 986
kerkeslager Avatar asked Jun 22 '10 23:06

kerkeslager


People also ask

How do I create a data file in Emacs?

You may also write the contents of the buffer to a different file with the command Control-X-Control-W. Emacs will prompt you for the name of the file you want to create. To create a new file, use Control-X-Control-F, just as if the file already existed.


1 Answers

There's also ESC-ESC-ESC (keyboard-escape-quit). From the manual:

The command ESC ESC ESC (keyboard-escape-quit) can either quit or abort. This key was defined because ESC is used to "get out" in many PC programs. It can cancel a prefix argument, clear a selected region, or get out of a Query Replace, like C-g. It can get out of the minibuffer or a recursive edit, like C-]. It can also get out of splitting the frame into multiple windows, like C-x 1. One thing it cannot do, however, is stop a command that is running. That's because it executes as an ordinary command, and Emacs doesn't notice it until it is ready for a command.

I find pressing ESC to be a natural response to the desire to "exit" a situation. Hammering it several times can also be emotionally satisfying when you are frustrated.

like image 85
zetetic Avatar answered Nov 30 '22 05:11

zetetic