Emacs’s undo system allows you to recover any past state of a buffer (the standard undo/redo system loses any “redoable” states whenever you make an edit). However, Emacs’s solution, to treat “undo” itself as just another editing action that can be undone, can be confusing and difficult to use: if you make an edit whilst in the middle of undoing multiple changes, you “break the undo chain”, and to get back to where you were, you have to undo all the undos you just did, then undo all the changes you’d already undone before, and only then can you continue undoing from where you left off. If this sounds confusing, it’s because it is! Hence, a number of packages exist that replace it with the undo/redo system (see CategoryUndo).

Both the loss of data with standard undo/redo and the confusion of Emacs’ undo stem from trying to treat undo history as a linear sequence of changes. undo-tree-mode instead treats undo history as what it is: a branching tree of changes (the same system that Vim has had for some time now). This makes it substantially easier to undo and redo any change, while preserving the entire history of past states. The undo-tree visualizer helps, particularly in complex cases. An added side bonus is that undo history can in some cases be stored more efficiently, allowing more changes to accumulate before Emacs starts discarding history. Undo history can be saved persistently across sessions with Emacs 24.3 and later. It also sports various other nifty features: storing and restoring past buffer states in registers, a diff view of the changes that will be made by undoing, and probably more besides.

For more information, see the Commentary at the top of the undo-tree.el file.


The undo-tree package is available from GNU ELPA in recent Emacsen, and in el-get. The latest “stable” version (version 0.6.4, released August 2013) can also be downloaded from:

If you want to live on the bleeding edge, the latest “development” version can be found in a git repository located at:

This is a git repository, not a web page. You cannot view it in a web browser. To grab the latest development version, clone the repository using:

    git clone http://www.dr-qubit.org/git/undo-tree.git


Please send bug reports and suggestions to toby-undo-tree@dr-qubit.org (you can post them here as well if you like, of course). I don’t check this page regularly, so anything not emailed to me is likely to languish here unnoticed for some time.

If you have code you would like to contribute to undo-tree, either send a patch against the latest development version to toby-undo-tree@dr-qubit.org, or better still, use git, rebase your work against the latest git master, and let me know where to find your clone of the undo-tree repository so that I can pull your changes.



Showing the undo-tree visualizer, with some undo states stored in registers, and the visualizer’s diff view: