"Florian Kaufmann" <sensorflo@gmail.com> writes:
Hello
Isn't it possible to bind a key to command such that this definition is
effective in all major & minor modes? In my particular case I'd like to
bind forward-char and backward-char to C-j and C-l respectively. But I
'd like to write this definition only once, and not for all minor and
major modes which overwrite the global map. For example currently in my
init.el I not only have to write
(global-set-key [(control j)] 'backward-char)
(global-set-key [(control l)] 'forward-char)
but disturbingly also
(add-hook 'c++-mode-hook
'(lambda ()
(define-key c++-mode-map [(control j)] 'backward-char)
(define-key c++-mode-map [(control l)] 'forward-char) ))
And I also have to add lines for countless of other modes I intend to
use.
Yes, that's what you have to do.
The mode shall decide what keybindings are good for you.
If you want to avoid it globally, the best that could be done is to
advice define-key and local-set-key, etc, to filter out unwanted mode
bindings.