0

Suppose, you type a shortcut key in emacs (say M-x) and you realize that you did not want to do it. How do you undo a shortcut that you already typed?

I have tried Esc-d but that doesn't seem to do what I want. Typing C-g after a wrong input says that the shortcut is not defined.

What I want is a way to immediately come out of all the typed shortcuts and execute new shortcuts immediately.

I hope my problem seems clear.

Chirag
  • 1,189
  • 2
  • 21
  • 43
  • Suppose I typed `C-x` by mistake, then if I press `C-g`, it says `C-x C-g undefined`. – Chirag Aug 07 '12 at 15:49
  • This is a desired behavior. C-g is always cancel, so if you have a long keybinding there should never be a C-g anywhere in it. Therefore using C-g will say undefined and cancel. – Nicolas Dudebout Aug 07 '12 at 15:50
  • There are other shortcut combinations, that will also give the same message ("not defined"). Then what makes `C-g` different from those other key combinations (eg: pressing `Esc-d`) – Chirag Aug 07 '12 at 16:01
  • C-g is reserved for cancelling. So doing C-g **anywhere** will **always** cancel the command. Esc-d can be bound in the middle of another shortcut. For example try Esc-d in a buffer and you will see that it tries to cut the word at point. – Nicolas Dudebout Aug 07 '12 at 17:06

1 Answers1

3

Cancel is C-g in emacs no matter what the context is.

Nicolas Dudebout
  • 9,172
  • 2
  • 34
  • 43