3

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?

1
  • 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.
    – Drew
    Jul 6 at 22:24
7

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?

11
  • 2
    A 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.
    – db48x
    Jul 6 at 11:55
  • Does the link at the end work? In my case (Chrome on Fedora 33) it appears as a plain text URL, but when I try to edit the answer, it appears as a proper link - canceling out of the edit leaves it as a plain text URL. What the ...? It's plain text on Firefox as well.
    – NickD
    Jul 6 at 13:35
  • @NickD Looks like a bug in the server-side markdown→HTML renderer. It does render as expected in the preview, which is a link to a question on the same site where the text is the question title. Jul 6 at 13:53
  • 1
    But at least org-mode violates this convention, because it uses C-c a and C-c l.
    – ceving
    Jul 6 at 15:57
  • 1
    Those are suggested key bindings. IOW, you have to take action to set them that way (or not). See orgmode.org/manual/Activation.html#Activation
    – NickD
    Jul 6 at 16:30
2

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.

1
  • However, 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. Jul 25 at 10:17
1

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.

0

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 own system of bindings, so move whatever bindings Emacs provides that conflict with your own choices.

Constructing your own consistent system for key bindings is a huge amount of work, but I don't think there's a way around it, since the Emacs developers give almost no guidance. Most other editors are no better than Emacs, and often worse, in this regard, even including recent editors like VS Code that are generally much better designed and more powerful than Emacs. (vim is a possible exception.)

I use all of the modifiers (Shift, Control, Alt, Meta, Super, and Hyper) in various combinations, along with multi-key bindings. Also, remember, the modifiers exist as physical hardware keys, as OS constructs, and as Emacs constructs. You can modify the mapping of hardware to OS, and also the mapping of OS to Emacs, which allows a lot of flexibility in choosing the most convenient mappings. You'll almost certainly want to reassign the caps lock key to something useful, and assign left and right option/alt, command/windows modifiers to different Emacs modifiers.

(I'm old enough to remember the ridiculous situation in the old days, of having to constantly peck at the Escape key to invoke Meta, even though most keyboards had more convenient keys that could have been assigned.)

I do not hesitate to remap the functions in packages I use, if they are inconsistent, awkward, thoughtlessly chosen, or simply inconsistent with my own philosophy.

I also think it's wise to bind Emacs functions that have standard keybindings for your OS to be consistent with your those. The common desktop operating systems probably have several dozen to several hundred such standard bindings and they should be remapped in Emacs, freeing up precious resources from your brain. (For instance, search, help invocation, frame cycling, minimization, etc., )

3
  • Welcome to emacs.se! Can you clarify how your post answers OP's question?
    – Dan
    Jul 25 at 19:28
  • @Dan Yes. I'm building on previous postings that indicate that 1) Emacs hardly "reserves" any prefixes for end users, but 2) allows any sequence to be arbitrarily rebound by the user. I'm going on to point out that 1) the keys "left over" are inadequate for most long term Emacs users, and 2) the standard keybindings are not organized well enough to be worth preserving. Therefore, my proposal is the OP not be afraid to systematize their own keybindings and rebind whatever Emacs command might be masked to other key sequences. Jul 25 at 20:43
  • @Dan I'm also giving specific advice on where to find large numbers of free key sequences, for instance by using all 6 of the Emacs modifiers. There are 64 possible combinations of these, and 99% of these are not used by any Emacs or package command. Jul 25 at 20:57

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.