I want to delete char backwards using C-d
, not the backspace key. I could do it like that:
(global-set-key (kbd "\C-d") 'delete-backward-char)
However, I have noticed that in fact backspace points to different functions in different major modes. For example, in lisp-mode it is backward-delete-char-untabify
function, in C mode c-electric-backspace
, in Help mode it is cua-scroll-down
. Is it possible to emulate backspace behaviour with C-d
without remapping it for every major mode separately?
I also tried this:
(global-set-key (kbd "\C-d") (kbd "<DEL>"))
But it obviously turns every C-d
key into <DEL>
, so keybindings such C-c C-d
stop working, making this not a suitable solution either.
P.S. I am slightly suprised that (as it seems after some googling) not so many people rebind backspace key. You have to take away your hand from home row every time you need to delete a character! This is so uncomfortable...how do you, Emacs people, delete characters?
delete-backward-char
instead of rebinding<DEL>
and it works so far for me.C-d
key into<DEL>
, so keybindings such asC-c C-d
stop working" - are you sure about that? When you pressC-c
(orC-x
, orC-h
) another keymap becomes active, in whichC-d
should NOT be overwritten. As per this doc: gnu.org/software/emacs/manual/html_node/elisp/Prefix-Keys.html