Next: , Previous: , Up: Mastering Key Bindings in Emacs   [Index]


5.5.3 Key Bindings

Key binding means to map keys to commands. "Keymaps" record keybindings. Modes define their own key bindings, so activating a mode might override custom key bindings.

A small number of keys are reserved for user-defined bindings and should not be used by modes. The reserved key sequences are those consisting of ‘C-c’ followed by a letter, and function keys ‘<F5>’ through ‘<F9>’ without modifiers.

There are several ways you can define (or undefine) keys.

(define-key KEYMAP KEY DEF)

Defines a key against a keyboard map. Use this if you want to change a keymap that isn’t the current buffer map.

(local-set-key KEY COMMAND)

Binds a key to the local keymap used by the active buffer, unlike define-key which takes an explicit keymap to bind a key against.

(global-set-key KEY COMMAND)

Binds a key to the global keymap, making it available in all buffers (with a caveat—see below.)

(global-unset-key KEY)

Removes KEY from the global keymap

(local-unset-key KEY)

Removes KEY from the active, local keymap.