C-h
b
shows the key bindings. But I can not see, which prefix is left for my own functions. Is any prefix reserved for user bindings?
-
All keys are available for users to rebind as they like. All of them. But when you say "left" do you mean reserved for users? If so, see @Gilles's answer.– DrewCommented Jul 6, 2021 at 22:24
-
Unfortunately, Emacs dropped the ball on systematizing key bindings. If you use Emacs long enough, you're eventually going to acquire enough custom functions that you won't be able to find convenient bindings for them all, and/or won't be able to remember them, unless you do what the Emacs developers should have done a long time ago, which is adhere to a consistent philosophy of how to choose bindings. In the long run, I think it's too confining to try to stick to Emacs's own keybindings for everything. Of course, I wouldn't change them willy-nilly, but I recommend giving precedence to your ow– AddlaiCommented Jul 25, 2021 at 10:58
3 Answers
As stated in the manual:
A small number of keys are reserved for user-defined bindings, and should not be used by modes, so key bindings using those keys are safer in this regard. The reserved key sequences are those consisting of
C-c
followed by a letter (either upper or lower case), and function keys F5 through F9 without modifiers
In practice, C-S-letter is not officially reserved but I don't remember ever seeing a mode using it.
Additionally, some standard bindings on control-letter combinations tend not to be useful because you can use the arrow keys instead. This gives you C-p
, C-n
, C-b
and C-f
. Also C-a
and C-e
if you have Home and End keys. And all standard bindings only use the modifiers Ctrl, Shift and Meta (C
, S
, M
) (or if there's any standard binding using another modifier, it duplicates another binding because those are the only three modifiers that everyone has), so if there's another modifier on your keyboard and it isn't reserved by your window manager, you can use that.
You can also free Ctrl+H, Ctrl+I, Ctrl+J and Ctrl+[ by using Tab, BackSpace, Return and Escape instead, however those are trickier to use because the function keys are processed as the control-character combinations in Emacs. For example, TAB
is the same thing as C-i
, so if you want to give Ctrl+I its own binding, you have to re-route it to something that is not C-i
. See How to bind C-i as different from TAB?
-
2A lot of people using the Emacs GUI will rebind
C-z
as well, since they don’t need a shortcut for iconifying an Emacs frame. Even in a terminal you have the option of opening a shell inside Emacs rather than suspending Emacs to use the shell.– db48xCommented Jul 6, 2021 at 11:55 -
2
-
1Those are suggested key bindings. IOW, you have to take action to set them that way (or not). See orgmode.org/manual/Activation.html#Activation– NickDCommented Jul 6, 2021 at 16:30
-
1"if there's another modifier on your keyboard and it isn't reserved by your window manager..." -- I've never used a window manager that I didn't reconfigure almost immediately to stop conflicting with my Emacs keybindings. In general, I disable all key bindings that I don't need from a window manager, and ensure the remainder are bound to non-conflicting keys.– philsCommented Jul 7, 2021 at 4:18
-
1I have to admit, I almost fell out of my chair to see you recommending using arrow keys in preference to C-p, C-n, C-b, C-f, C-a, and C-e. I would never dream of doing that, because of the loss of speed and the fatigue from the constant hand shifts to do that. But to each his own.– AddlaiCommented Jul 25, 2021 at 11:21
Just override any key that you don't use. Check what (if anything) is binded to a key with C-h k or install which-key-mode. You could also install something like worf or hydra make more room.
-
1However, if the binding is global, you need to check whether the binding conflicts with anything in every mode you use. A key sequence that is not bound when you're in your init.el file (hence in Emacs-Lisp mode), might well be bound in, say, Python mode.– AddlaiCommented Jul 25, 2021 at 10:17
Not yet mentioned, I'd like to recommend re-binding one of C--
or M--
, since they both serve the same purpose. Then you have an entire key free to use.