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.