There are two bindings for undo-tree-undo(C-_ and C-/) and undo-tree-redo(M-_ and C-?) defined in undo-tree, but now I don't want those bindings(delete those), I just want to bind C-z to undo-tree-undo and C-S-z to undo-tree-redo(short and simple), I tried

(define-key undo-tree-map (kbd "C-_") nil)


(global-unset-key (kbd "C-_"))

to delete the bindings, they all doesn't work(only work for current session), if I restart Emacs, the C-_ will still be bound to undo-tree-undo.

But if I set above two lines at the same time, the binding will be gone, that's really weird, how can I use one line to delete the bound.

BTW, if you can delete the old bindings and set the new binding(C-z) at the same time, that would be better?

  • I'm going to suggest something that no forum participant will like: It may be time to take complete control of your libraries and modify them to suit your personal needs instead of trying to tweak them here and there.
    – lawlist
    Commented Dec 7, 2014 at 8:29

1 Answer 1


To make these bindings persistent, put them into your init file. For them to be able to redefine the undo-tree keymap, undo-tree has to be active first. This can either be guaranteed by enabling undo-tree first (which only works after the packages have been enabled in the respective after-init-hook or after using package-initialize in your init file) or by applying them after its file has been loaded with eval-after-load.

As for rebinding existing functionality, you're able to remap a command to another or swap out a command for the keybinding in question. Neither of those are what you're after. Here's a snippet you can put in your init file that's using `eval-after-load' and explicitly rebinds everything:

(eval-after-load 'undo-tree
     (define-key undo-tree-map (kbd "C-/") nil)
     (define-key undo-tree-map (kbd "C-_") nil)
     (define-key undo-tree-map (kbd "C-?") nil)
     (define-key undo-tree-map (kbd "M-_") nil)
     (define-key undo-tree-map (kbd "C-z") 'undo-tree-undo)
     (define-key undo-tree-map (kbd "C-S-z") 'undo-tree-redo)))
  • I have package-initialize at the beginning of my init file. Although I got C-/ bound to helm-semantic-or-imenu in my init file, C-? bound to ispell-complete-word in my init file, they still have to be (define-key undo-tree-map (kbd "...") nil)(or the manually binding to helm.. and ispell.. will not work), the two and M-_ can be disable using only one line without eval-after-load, but the goddamn C-_ is still there. I think maybe the C-_ is builtin for undo in emacs -q, and M-_ is not.
    – CodyChan
    Commented Dec 7, 2014 at 0:58
  • I'll just take special care of C-_, put the two lines at the same time if there is no better solution. But still thanks.
    – CodyChan
    Commented Dec 7, 2014 at 1:00

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.