I normally undo with
ctrl+_ with other editors there is a redo operation normally associated with
ctrl+y. is there an emacs equivalent?
In general what is the best way to handle an "undo tree"?
Emacs Stack Exchange is a question and answer site for those using, extending or developing Emacs. It only takes a minute to sign up.Sign up to join this community
The commentary at the outset of the
undo-tree.el library describes two built-in methods to undo and redo: https://github.com/emacsmirror/undo-tree/blob/master/undo-tree.el#L87
;; C-_ C-/ (`undo-tree-undo') ;; Undo changes. ;; ;; M-_ C-? (`undo-tree-redo') ;; Redo changes.
The mode key map does not follow the normal naming convention, and instead the map is named
undo-tree-map. You can set up any keyboard shortcut that you want.
Q: In general what is the best way to handle an "undo tree"?
A: Read the commentary once for a general understanding, and then read it again a second time to catch anything you may have missed the first time around. Beware that killing the visualization buffer by brute force leaves
#<marker in no buffer> in the
buffer-undo-tree and that causes
read to choke when trying to restore from a saved history file if using the persistent save/restore feature. Older versions of the
yasnippet library leave
#<overlay in no buffer> inside the
buffer-undo-tree that can make their way into the saved history file, which cause the same problem with persistent save/restore. [@npostavs has provided a link in the comment below to the
yasnippet pull request that resolves unreadable leftovers remaining in the
buffer-undo-tree.] To kill the visualization buffer, either type the letter
q in the visualization buffer, or edit the parent buffer and it will close automatically --
kill-buffer is what I meant by brute force. There are some other bugs, but it is a fun library to play with. Rumor has it that someone forked it and is working on certain new features and bug fixes ....