Getting started with emacs, keyboard

Configuration outside of emacs

Free key sequences from OS for use with emacs

Emacs = Esc Meta Alt Ctrl Super (quoted from here).
Emacs utilizes many more key combinations than other applications. But it can't do that if the operating system grabs key sequences first for its own purposes.

Many desktop environments define a long list of "shortcuts" or "hot keys" by default. Many of which you never use and may not even be aware of. As an emacs user it is good to unbind the ones you don't use; both for the obvious reason that emacs can now use those key sequences, but also because when using emacs (and therefore pressing (Esc Meta Alt Ctrl Super) often), you will be much more likely to accidentally type shortcut key sequences.

I use debian linux with the xfce desktop environment so I use that as an example. Xfce (version 4 at least) has a menu under Application/Settings/Window Manager/Keyboard where you can turn off keyboard shortcuts. I like to use alt tab to cycle windows, but I turn most of the other bindings off.

Remapping keys on your keyboard

The (Esc Meta Alt Ctrl Super) keys heavily used by emacs are not always conveniently placed on your keyboard. For example the ctrl key is often small and inconveniently placed. Fortunately, you can remap the keys on your keyboard with few restrictions. The classic example being modifying the configuration so that the CapsLock key acts as a control key.

The details of keyboard configuration depend on the operating system you use. For linux users the main tools are xkbcomp and xev. I suggest this explanation on archlinux.org. The details are bit complicated, but it is worth the effort to be able to make your keyboard do what you want.

Emacs and key sequences

key presses = function call

In any application that responds to the keyboard, user key presses somehow affect the execution of the application. In Emacs this relationship is transparent and accessible to users. The flexible key binding facility of emacs is one of its strong points. In emacs-speak, a "command" is simply a function which can be called via pressing a key (or doing something with the mouse etc). The command execute-extended-command, with default key binding M-x can be used to invoke commands by name; where M-x denotes the key sequence: hold the alt key down and then press x (or alternatively press Esc and then press x. For example try pressing M-x and entering forward-char at the prompt. In most types of buffers, it should have the effect of moving the cursor forward one position. At the start the most important functions to know are:

Start with the default key bindings...

If you are new to emacs, I recommend using the default key bindings for a while. Mainly because a lot of emacs documentation refers to user commands by their default keybinding instead of their function name. For example, to move the cursor forward one position a tutorial will likely tell you to press control-f, instead of telling you to invoke forward-char.

If you use emacs a lot, eventually you will want to change your key bindings for all kinds of commands: built-in commands, commands you import from packages, and commands you write for yourself. A nice feature of describe-function is that links to the implementation of any emacs function (or special form) even if it is implemented in C (See viewing emacs C src code).

Binding keys to commands in emacs

I recommend the bind-key package to manage key bindings.

I hope to write a section on key binding soon...

keymaps and prefix keys

Quoting the elisp manual info page, a prefix key is a key sequence whose binding is a keymap. Those keymaps and prefix keys are described well there, so for now I just give a useful tip.

One can use C-h or the F1 key to display all completions of a prefix key (or more generally a prefix sequence). Suppose for example, you are curious to know what key bindings start with C-x. An easy way to display that information is to press C-x followed by C-h or F1, which should cause emacs to display information about key bindings starting with C-x in a *Help* buffer. The prefix sequence can be more than just a single key, for example try C-x 8 ' C-h to see some commands for inputting letters with acute accents such as Á and ý. Alternatively, one can use the describe-keymap command if you know the name of the relevant keymap (ctl-x-map for example).