Difference between revisions of "Key Bindings"

From WikEmacs
Jump to: navigation, search
(link to excellent blog post)
Line 1: Line 1:
 +
In Emacs, almost any keystroke, optionally combined with one or more [[#modifierKeys|modifier keys]], or any sequence of such keystrokes, can be "bound" to any [[command]].
 +
 +
== Modifier keys naming convention ==
 +
 +
{| class="wikitable"
 +
|-
 +
! Modifier key
 +
! Abbr.
 +
! Remarks
 +
! Example
 +
! Action
 +
|-
 +
| Alt
 +
| A
 +
| Relatively seldom used in Emacs, because Meta is often "logically" mapped to the "physical" <tt>Alt</tt> key.
 +
| A-x
 +
| Type "x" while holding down the (non-Meta) Alt key
 +
|-
 +
| Control
 +
| C
 +
|
 +
| C-x C-f
 +
| While holding down Ctrl, type first "x" then "f". (This runs the command <tt>find-file</tt>).
 +
|-
 +
| Hyper
 +
| h
 +
| Often not mapped to any key (by default).
 +
| h-x
 +
| Type "x" while holding down hyper
 +
|-
 +
| Meta
 +
| M
 +
| Often mapped to <tt>Alt</tt> on your keyboard
 +
| M-x find-file RET
 +
| Either:
 +
* type "x" while holding down Meta, or
 +
* type "Esc" then "x",
 +
which activates the [[minibuffer]], then type "find-file" in the minibuffer, then Return.
 +
|-
 +
| Shift
 +
| S
 +
|
 +
| S-x
 +
| Type "x" while holding down Shift
 +
|-
 +
| Super
 +
| s
 +
| Often not mapped to any key by default, or to <tt>Window</tt> or <tt>Menu</tt> if present
 +
| s-x
 +
| Type "x" while holding down super
 +
|-
 +
|}
 +
 +
 
== Printable cheat sheet for popular modes ==
 
== Printable cheat sheet for popular modes ==
 
Emacs ships with cheat sheets of common and useful key bindings.
 
Emacs ships with cheat sheets of common and useful key bindings.

Revision as of 16:59, 29 March 2012

In Emacs, almost any keystroke, optionally combined with one or more modifier keys, or any sequence of such keystrokes, can be "bound" to any command.

Modifier keys naming convention

Modifier key Abbr. Remarks Example Action
Alt A Relatively seldom used in Emacs, because Meta is often "logically" mapped to the "physical" Alt key. A-x Type "x" while holding down the (non-Meta) Alt key
Control C C-x C-f While holding down Ctrl, type first "x" then "f". (This runs the command find-file).
Hyper h Often not mapped to any key (by default). h-x Type "x" while holding down hyper
Meta M Often mapped to Alt on your keyboard M-x find-file RET Either:
  • type "x" while holding down Meta, or
  • type "Esc" then "x",

which activates the minibuffer, then type "find-file" in the minibuffer, then Return.

Shift S S-x Type "x" while holding down Shift
Super s Often not mapped to any key by default, or to Window or Menu if present s-x Type "x" while holding down super


Printable cheat sheet for popular modes

Emacs ships with cheat sheets of common and useful key bindings. The pdf files are located in the refcards/ subdirectory of data-directory.

Editing key bindings

You can add, remove and change key bindings for any command, either globally or locally to a mode, interactively (and only for the current session) via M-x global-set-key and M-x local-set-key, or persistently using simple Emacs Lisp code in your Emacs configuration file which is loaded when Emacs first starts up.

External Links