I know that emacs is often critzied because of its shortcuts. But this isn't the intention of that question! I come in peace! ;)

I was using vim for years. And I see a concept behind of the most shortcuts there. e.g. You don't have to move your right hand/fingers away from the basic-position on the keyboard to navigate in your file.

I did the emacs tutorial and couldn't get into it. Why are the shortcuts this way? Even the basic ones. They are hard to remember and hard to press. In my opinion I have to move and combine my fingers in a unnatural way.

It would help me to get deeper into emacs if I would understand the concept behind that keys. It was the same for me in vim. The first time it was damn crazy. But when I understood it everything went nice and easy. ;) I am looking forward to work with emacs the same way.

Another side question would be why are CTRL and ALT are renamed in emacs? From the viewpoint of a beginner it doesn't help. It just underline the "exoctic" status of that genius piece of software.

btw: I know the evil-mode and that emacs is able to modify nearly everything I want. But that shouldn't be the starting point for a emacs-beginner.

  • 7
    Actually, a good amount of them is mnemonic. According to Coders at Work, the current keybindings are a result of Guy Steele reconciling the six different popular Emacs keybinding sets at that time...
    – wasamasa
    Aug 16 '16 at 6:39
  • 2
    Don't look for a deeper meaning, where there is none. The default key-bindings are one of the worst parts of Emacs.
    – politza
    Aug 16 '16 at 7:25
  • 1
    I guess the usual pattern is "Make something out of modifier keys and the first letter of whatever describes what the command is doing". E.g. C-b (backward), C-p (previous line). Then in the fine print you'll find "if that doesn't work, be creative".
    – YoungFrog
    Aug 16 '16 at 12:04
  • I would say historical growing. Keys were added when needed, and never changed.
    – Arne
    Aug 16 '16 at 13:13
  • @Arne: Not true that keys have never changed, once added. What is true is that changing a commonly used default key binding involves a fair amount of reasoned discussion among Emacs developers and other Emacs users. One reason for this, but not the only one, is that users get used to things... But Emacs users have requested default changes, and such changes have occurred. Besides other reasons, including user-base habits, the fact that it is so easy to define your own preferred key bindings makes the choice of defaults less important. Nevertheless, Emacs takes defaults very seriously.
    – Drew
    Aug 16 '16 at 15:27

Unlike vi, Emacs does not have two completely separated modes, one for issuing commands and one for inserting text. This means that self-inserting keys such as letters self-insert (duh). And that means that they cannot simultaneously be used to invoke commands (other than the command to self-insert -- in Emacs all user interactions invoke commands, in fact).

So Emacs had to use other key combinations to invoke commands. (And this was also before there were things like a mouse, graphic-display, and window managers.) The ASCII control keys, using the Ctrl key, were the natural answer. Using them you can mix self-inserting keys with command-invoking keys.

There is only one Ctrl key, so the commands you can invoke using it are (were, especially, at the time Emacs was created) limited in number. There is also the Escape key (ESC) key, and that too was put to use for invoking commands, as a prefix for key sequences.

There is also an Alt key (aka Meta, typically), which in some cases allowed for a shortcut from using ESC-prefixed keys.

Most key typing involves self-inserting keys. A minority involves invoking commands. So this combination worked pretty well.

Beyond that is the question of which key sequences to use for what commands. This was carefully worked out, with experimentation -- and it continues to be. Here are some of the basic ideas, which other posts here might go into, and which you can easily find more about elsewhere:

  • Often-used commands, and often-used sequences of commands, should have relatively easy-to-use key sequences. Commands used less often can have harder-to-use keys.

  • Seldom-used commands need have no key sequence. Any command can be invoked using a simple-to-use key (M-x) that prompts for you to enter its name.

  • Keys easy to reach by the stronger, longer fingers and the thumbs are generally easier to use often. This means keys like f, e, g, v, b, j, i, o, m, n, SPC, DEL (Backspace), etc.

  • Because there are many commands, and thus many command-invoking key sequences, users need some help keeping track of them. For this, Emacs defined help keys, including C-h c and C-h k, which describe keys, and C-h w which tells you what key to use for a command name you type at the prompt. This is behind the strong commitment that Emacs be a self-documenting editor - just ask it about itself. At the time Emacs was created, this was a new idea, and it is still an idea that is stronger in Emacs than elsewhere.

  • For the same reason, some degree of organization of the many key sequences, providing some symmetry and other mnemonic aids, was called for. This is behind the system of using C-f, M-f, C-M-f, C-b, M-b, C-M-b, etc., with "f" signifying "forward" and "b" standing for "backward".

The rest is history: evolution, adaptation, suggestions and experiments by thousands of people.

Oh, did I forget to say that because Emacs uses modifier and prefix keys to invoke specific commands, binding keys to commands is very important, and because it is important, users need to be able to do this themselves? This is behind the strong commitment that Emacs be a customizable editor.

Predefined keys have no special significance. With a couple of somewhat-exceptions (you usually should not mess with C-u, ESC, or C-g), you can easily create your own system of key bindings - you can pretty much replace any and all of the predefined key bindings.

Does this help understand Emacs keys? It should help understand Emacs more generally, because in Emacs, everything -- every single user action, is a command. And any command can be bound to a key. Many commands are bound to keys by default, and you can bind others or rebind any that are bound.

In the end, the Emacs "crazy" keys are your own fault, in this sense: predefined keys are offered as a suggestion - something suggested that you can use out of the box, if you want. But you can easily create your own crazy-keys combinations and systematize things your own way.

"Another side question would be why are CTRL and ALT are renamed in emacs?"

Those are common labels for the physical keys. In Emacs (and other programs), there is a distinction between physical keys, the codes they send to applications, and the software representations of those codes.

In Emacs there is more than one soft representation of keys. In particular, there is an external, user-facing key-description representation, such as C-x 2 or <M-down> or C-M-f, which is what you provide to function kbd when you want to bind a key sequence. And there are internal, Emacs-Lisp representations, such as [M-down] and [(meta down)].

The aim of the external, user notation is to be succinct: C-M- instead of Ctrl + Meta, etc.

The reason Meta is used instead of Alt is that in fact both can be used. Alt is a physical key; you can move Meta pretty much wherever you like. Emacs users and programs generally use Meta, which is separated from hardware, instead of Alt, which is not. And they generally just accept the default assignment of Meta to the Alt key.

  • 2
    Just to point, Meta was an actual key modifier on Lisp machines from the 80s. Standard PC keyboards never had one, so it was remapped to Alt Aug 16 '16 at 17:37
  • 1
    Emacs as the family of editors is older. Can't say when Meta was introduced. ergoemacs.org/emacs/emacs_kb_shortcuts_pain.html and kb.iu.edu/d/aghb seem to think that it comes from the Meta key on Lisp machines. Doesn't seem logical to create a Meta key modifier without the actual key on a keyboard. Aug 16 '16 at 18:58
  • @MiyamotoAkira: It's possible that the first use of Meta in Emacs was borrowed from its use on a Lisp machine; I don't know. In any case, Emacs using Alt for Meta predates Emacs on PCs or with PC keyboards. Most use of Emacs in the 80s was on minicomputers and workstations.
    – Drew
    Aug 17 '16 at 4:49
  • 1
    This text should published somewhere!
    – buhtz
    Aug 17 '16 at 14:19
  • 2
    As one of the earliest users of emacs, I can report that the Meta- modifier was from a system called the Knight TV (terminal), used at the MIT AI Lab. It had a keyboard we jokingly called the "Space Cadet" keyboard. It actually had (IIRC) five modifier keys (Shift, Ctrl, Meta, Super, and Hyper). The LispM keyboards were modeled after these (actually, the first two LispMs [Cons and Cadr] used the Space Cadet keyboards originally).
    – MAP
    Aug 19 '16 at 8:01

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.