Using emacs vanilla undo, I'd like to undo a series of operations, then hold a key to redo only the operations I just undid, and only those operations.

This use case for example:

  • Hold undo key, copy some part of the old buffer.
  • Hold redo key until all operations have been redone. Then paste in the clipboard.

While this is possible with emacs undo, it's made inconvenient because (as far as I know) there is no way to make redo stop at the point after undo began. It reaches the recent state, then begins undoing, it's easy to mess, then it's tricky to get the exact latest point because the redoing is now added to the history.

Is there a way to detect this situation and prevent it from redoing non-undo operations?

This should be possible since Redo / Undo is displayed in the message buffer.

1 Answer 1


Emacs 28 adds a redo command (called undo-redo).

If you want to have more typical undo/redo, the following commands can be used.

(global-set-key (kbd "C-z") 'undo-only)
(global-set-key (kbd "C-S-z") 'undo-redo)

You can also check the package undo-fu which has this functionality, allowing to access the full non-linear undo history as well.

There is also undo-tree although I wouldn't recommend it because of known undo corruption problems.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.