Anda di halaman 1dari 3

Emacs Cheat Sheet

For COMP11
September 27, 2016

Command Key
All commands in Emacs follow a similar format and we will adopt the convention used in most
other resources to denote them:
C-<key>: Denotes holding the Ctrl key down while pressing <key>. For example, C-x means
hold down Ctrl and press the x key.
M-<key>: Denotes holding the Alt key down while pressing <key>. For example, M-x means
hold down Alt and press the x key. If Alt does not work for you, you can precede <key>
with Esc (If this is the case, dont hold down Esc).
If a command is followed by a single keystroke, we will write C-<key 1> <key 2>. For
example, C-x b means hold down Ctrl and press x, release both, and finally press b.
Some actions require two atomic commands in a row; this will be denoted, for example, as
C-x C-f. This means hold down Ctrl, press x, and then without releasing Ctrl press f.

Opening, Saving, and Closing


To open Emacs, simply type emacs <filename> in the terminal. If the file exists, you will
see its contents. If it does not exist, Emacs will provide you with an empty file.
At any point, you can save your work with the keystroke C-x C-s.
To close Emacs, use the keystroke C-x C-c.

Navigating the Document


Basic Navigation
On most machines, the arrow keys act as aliases for the following four commands so feel free to use
them instead if you find these hard to remember:
To move forward one character, use C-f (or the right arrow key).
To move back one character, use C-b (or the left arrow key).
To move down one line, use C-n (or the down arrow key).
To move up one line, use C-p (or the up arrow key).

Advanced Navigation
Rather than moving one character or line at a time, Emacs provides several other commands that
allow for faster navigation through larger files:
To move to the start of the line youre on, use C-a.
To move to the end of the line youre on, use C-e.
To move to the beginning of the paragraph youre working on, use M-a.
To move to the end of the paragraph youre working on, use M-e.
To move forward one whole screen of text, use C-v.
To move back one whole screen of text, use M-v.
To jump to the beginning of the file, use M-< (Thats M-Shift-,).
To jump to the end of the file, use M-> (Thats M-Shift-.).

Selection, Cutting, Copying, and Pasting


To select a region of text, use C-Spacebar and the navigational commands to highlight the
desired region.
To cut the current selection, use C-w
To copy the current selection, use M-w.
To paste what you cut / copied, use C-y (The y stands for yank).

Deleting Text
To delete a character, use Delete or C-d.
To delete a character and everything after it on the line, use C-k.

Summary / List of Commands


Open Emacs from terminal: emacs <filename>
Save: C-x C-s
Close: C-x C-c
Forward one character: C-f or right arrow
Back one character: C-b or left arrow
Next line: C-n or down arrow
Previous line: C-p or up arrow
Beginning of line: C-a
End of line: C-e
Beginning of paragraph: M-a
End of paragraph: M-e
Forward a screen: C-v
Back a screen: M-v
Beginning of file: M-<
End of file: M->
Set marker and select: C-Spacebar + Navigational commands
Cut text: C-w
Copy text: M-w
Paste text: C-y
Delete character: C-d
Delete character and rest of line: C-k

Anda mungkin juga menyukai