I want to get rid of the C-e
binding so I can bind C-e e
, and C-e r
to a command. How do I do this?
My .emacs is
(global-set-key (kbd "C-e e) 'move-end-of-line)
(global-set-key (kbd "C-e r) 'end-of-buffer)
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 want to get rid of the C-e
binding so I can bind C-e e
, and C-e r
to a command. How do I do this?
My .emacs is
(global-set-key (kbd "C-e e) 'move-end-of-line)
(global-set-key (kbd "C-e r) 'end-of-buffer)
You can unset the key in at least two ways:
(global-set-key (kbd "C-e") nil)
(global-unset-key (kbd "C-e"))
Note that I got this information with a web search for emacs unset key.
(global-unset-key (kbd "C-h h"))
.
– MattMS
Oct 16 '18 at 4:13
See @lawlist's comment.
Use C-h m
, C-h k
, and C-h b
wherever you want to make the change. That will help you figure out the keymap in which you need to make the change. If Dan's suggestion didn't help then clearly that keymap is not the global map.
Setting the key binding to nil
is indeed the way to unbind it. You just need to do that in the right map.
Using C-h M-k
(describe-keymap
), from library help-fns+.el
will give you a human-readable list of the bindings in a given keymap (bound to a keymap variable, such as global-map
.
C-h k
tell you in the buffer in question? If it says something like C-e runs the command move-end-of-line (found in global-map)
then the binding is from the global map, and (global-set-key (kbd "C-e") nil)
should be sufficient. If it is not then you will need to show us more context. And be sure to start from emacs -Q
(no init file) - we won't try to guess whatever might be in your init file and setup.
– Drew
May 13 '15 at 22:44
intangible' text or overlay property, bind
inhibit-point-motion-hooks' to t. If there is an image in the current line, this function disregards newlines that are part of the text on which the image rests.
– Joshua Lilleberg
May 14 '15 at 19:40
C-e
is bound to move-end-of-line
. And you try M-x global-unset-key C-e
and try C-h k C-e
and it still tells you that it is bound to move-end-of-line
. Right? Try doing that same thing after starting Emacs using emacs -Q
(no init file). No doubt it will work. If so, and if it doesn't work when you load your init file (just emacs
, not emacs -Q
), then something in your init file is causing the problem. Recursively bisect your init file to find what that something is. You can comment out 1/2, then 3/4, 7/8 etc. of your init file using command comment-region
.
– Drew
May 14 '15 at 20:07
You don't need to unset a key before you rebind it to something else. This should do what you want:
;; create a new prefix map
(define-prefix-command 'my-keymap)
;; bind the new keymap to C-e
(global-set-key "\C-e" my-keymap)
;; bind the individual commands:
(define-key my-keymap "e" 'move-end-of-line)
(define-key my-keymap "r" 'end-of-buffer)
Now hitting C-e
is a prefix, and C-e e
calls end-of-line
etc.
C-d
-- perhaps it would work for you usingC-e
instead? -- the help-for-help function is just an arbitrary example:(defalias 'ctl-d-keymap (make-sparse-keymap)) (defvar ctl-d-map (symbol-function 'ctl-d-keymap) "Global keymap for characters following C-d.") (define-key global-map "\C-d" 'ctl-d-keymap) (define-key ctl-d-map "z" 'help-for-help)
– lawlist May 13 '15 at 19:06C-h k C-e
? – Kaushal Modi May 13 '15 at 19:50C-e
, then those key bindings will trump a global setting -- minor trumps major, and major trumps global. So, you would need to do what kaushalmodi is suggesting to track down which of those circumstances is likely at issue. Once you figure that out, then you can unset those keys. Here is an example for unsetting org-mode key bindings (a major mode): stackoverflow.com/a/17540326/2112489 – lawlist May 13 '15 at 20:02