what is the command to undo in emacs

1 hour ago 3
Nature

The command to undo changes in Emacs is typically:

  • C-/ (Control + slash)
  • C-_ (Control + underscore)
  • C-x u (Control + x, then u)

Any of these commands will undo the most recent change in the buffer, moving the cursor back to where it was before that change

. To redo changes after undoing, Emacs does not have a dedicated redo command by default, but you can "undo the undo" by first pressing a harmless command like C-g (keyboard quit) or C-f (move forward), then pressing the undo command again (C-/ or C-_). This causes Emacs to reverse the direction of undoing, effectively redoing the changes you previously undid

. In summary:

  • Undo: C-/ or C-_ or C-x u
  • Redo: Press C-g (or another harmless command), then C-/ or C-_ again

This approach allows you to step backward and forward through your editing history. Some Emacs configurations or packages (like undo-tree.el) provide more conventional undo/redo behavior with dedicated redo commands, but the above is the standard built-in method

. Additional notes:

  • Repeating the undo command multiple times steps further back in the change history.
  • Any command other than undo breaks the undo sequence, enabling redo by undoing the undo.
  • To redo multiple steps, repeat the redo sequence (C-g then undo command) as needed

This system is powerful but can be initially confusing because undoing is itself recorded as an edit, allowing flexible navigation through the entire edit history.