Reputation: 11
I want to change the behavior of the key TAB
. I don't know if it's possible: I want to force TAB
to do what M-i
does.
Upvotes: 1
Views: 320
Reputation: 30718
Sounds like you want to remap the command that is bound to M-i
to TAB
.
If you want to do that in the global-map
then this does it:
(global-set-key (kbd "TAB") (kbd "M-i"))
If you want to do it in a particular keymap, say foo-map
, then this does it:
(define-key foo-map (kbd "TAB") (kbd "M-i"))
But typically users want to remap a command's keys to another command. For that you use [remap OLD-COMMAND]
as the first arg to global-set-key
or the second arg to define-key
, and you use the NEW-COMMAND
as the last arg.
Alternatively, for that you can use function substitute-key-definition
, which also lets you change keymaps. C-h f substitute-key-definition
starts with this:
substitute-key-definition
is a compiled Lisp function insubr.el
.
(substitute-key-definition OLDDEF NEWDEF KEYMAP &optional OLDMAP)
Replace
OLDDEF
withNEWDEF
for any keys inKEYMAP
now defined asOLDDEF
.In other words,
OLDDEF
is replaced withNEWDEF
wherever it appears. Alternatively, if optional fourth argumentOLDMAP
is specified, we redefine inKEYMAP
asNEWDEF
those keys which are defined asOLDDEF
inOLDMAP
.
Upvotes: 2