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 communityI 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"?
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 ....
undo-tree
package? With default Emacs behavior there is no redo command. You can make another edit (hit SPC or whatever) and then call undo as many times as needed to get back to what you want. – glucas Jun 25 '17 at 12:23undo-tree
, if you really think you need a specific redo feature. Most Emacs users just undo the undo to get pretty much the usual effect of a redo. E.g.C-_
to undo, followed by something else (e.g. insert a char), which breaks out of undoing, followed byC-_
twice, to undo the inserted char and undo the first undo. – Drew Jun 25 '17 at 15:50