There are a variety of ways to “undo” something in Emacs. Unfortunately some of the keystrokes work in some environments, while others do not. Here’s a quick rundown:
Meta-x undo
— Will undo only the most recent changes. Cannot be used multiple times.Ctrl-x u
— Undo. Consecutive repetitions will undo earlier and earlier changes.Ctrl-_ or Ctrl-/
— Same as Ctrl-x u, however does not work in some envrionments.Ctrl-Shift-Minus
— Same as Ctrl-x u, however does not work in some environments.
For whatever reason I can never remember the Ctrl-Shift-Minus
sequence when I find myself in an environment where Ctrl-_
and Ctrl-/
don’t work.
Keep in mind that Emacs undo is a bit different from traditional undo: Undo actions themselves are recorded as actions. This can be confusing.
In some environments, Ctrl-x Ctrl-_
will reverse the order of undo. I avoid this out of fear that it will cause the universe to implode.
See the Emacs info node for more good undo lore, such as how to use “selective undo” which restricts undo actions to changes performed in the current active region. (Very useful.)