Is there a way to configure emacs so that a keybinding will just issue another one? In particular, I want to configure it so that C-t replicates (or even better replaces) backspace. I couldn't find a way to do it in my Window Manager (I am not even sure if it is at all possible in any Window Manger) so I have to do it in Emacs.

At the moment, I am just mapping C-t to backward-delete-char but this is not ideal, because many packages map backspace and I would have to go over all keymaps and replace backspace with C-t.


A key sequence is just one possible form of a command. So you can just use the following form (if I understand your question right):

(global-set-key (kbd "C-t") (kbd "<backspace>"))

You can replace backspace with C-t by translating it in input-decode-map:

(define-key input-decode-map (kbd "C-t") (kbd "<backspace>"))
(define-key input-decode-map (kbd "<backspace>") [7])

The second form replaces backspace with the ASCII bell character. The harmless keyboard-quit command is bound to that character.

Note that there is already a duplicate of this question but the following statement in that question is wrong:

I also tried this:

 (global-set-key (kbd "\C-d") (kbd "<DEL>"))

But it obviously turns every C-d key into , so keybindings such C-c C-d stop working, making this not a suitable solution either.

See also the corresponding comment of VanLaser:

You say "it obviously turns every C-d key into , so keybindings such as C-c C-d stop working" - are you sure about that? When you press C-c (or C-x, or C-h) another keymap becomes active, in which C-d should NOT be overwritten. As per this doc: https://gnu.org/software/emacs/manual/html_node/elisp/Prefix-Keys.html

| improve this answer | |
  • That's exactly it. Thanks for this. Is there a way to replace the backspace rather than replicate it? So somehow map <backspace> to 'ignore and map C-t to whatever <backspace> was mapped to. – Tohiko Mar 5 at 14:35
  • @Tohiko See C-h i g (elisp)Remapping Commands – phils Mar 5 at 17:51
  • @phils He does not want to remap the delete-backward-char command since depending on the major mode many other commands are bound to the DEL key. – Tobias Mar 5 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.