"C-" (control) means "hold down Ctrl key" |
"M-" (meta) means "hold down Alt/Option key", or "press and release Esc key" |
Category | Command | Keystrokes | Mnemonic |
Start/Stop | start emacs (in Terminal) | emacs -nw | |
exit emacs | C-x C-c | ||
Files | read a file into Emacs | C-x C-f | find |
create a new file (name it as if it exists) | C-x C-f | find | |
insert a file | C-x i | insert | |
save | C-x C-s | save | |
save as ... | C-x C-w | write | |
Cursor Motion | forward (right arrow) | C-f | forward |
backward (left arrow) | C-b | backward | |
down (down arrow) | C-n | next | |
up (up arrow) | C-p | previous | |
C-a | a = start alphabet | ||
C-e | end | ||
M-< | < = left | ||
M-> | > = right | ||
Cut, Copy, Paste
"kill" = "cut", "yank" = "paste" |
delete current character | C-d | delete |
delete previous character | Backspace | ||
kill to end of line (twice to include newline) | C-k | kill | |
set mark; "region" is between invisible "mark" and "point" (cursor) | C-SPACE | ||
kill region | C-w | ||
copy region | M-w | ||
yank back last thing killed | C-y | yank | |
M-y | |||
C-x r k, C-x r y | |||
Formatting | indent current line | TAB | |
indent buffer | M-x indent-region |
||
fill paragraph | M-q | ||
Error Recovery | abort partially typed or executing command | C-g | |
undo an unwanted change | C-_ or C-/ | undo | |
M-x revert-buffer | |||
The Minibuffer | complete as much as possible | TAB | |
Type C-x ESC ESC to repeat the last command that used the minibuffer. Then the following keys are defined. | previous minibuffer command | M-p | previous |
next minibuffer command | M-n | next | |
Multiple Buffers | C-x 1 | one | |
C-x 2 | two | ||
C-x 3 | |||
C-x o | other | ||
(Each can use a prefix argument via C-u; e.g. C-u -10 C-x ^ goes taller -10 lines.) |
C-x } C-x { C-x ^ |
right left up |
|
Buffers | C-x C-b | buffer | |
type SPACE (or f) on the buffer's line | find | ||
C-x k | kill | ||
M-x shell | |||
Incremental Search
Then type a word for which to search. Use C-s or C-r again to repeat the search in either direction. |
search forward | C-s | search |
search backward | C-r | reverse | |
C-M-s or C-M-S | |||
C-M-r or C-M-R | |||
exit search | Enter | ||
M-x occur | |||
Query Replace
yes = "y" or SPACE, no = "n" |
interactively replace text | M-% (or M-x query-replace) | |
M-x query-replace-regexp | |||
Regular Expressions for search and query replace | |||
Directory Editor to list and manage files
find directory (C-x C-f . ), then "?" for help |
delete (rather, mark for deleting) | d | |
u | |||
expunge (delete files marked for deleting) | x | ||
find | f | ||
rename | R | ||
copy | C | ||
create directory | + | ||
refresh directory | g | ||
R | M-x R | ||
C-c C-n | from within a ".R" file | ||
C-c C-c | chunk | ||
C-c C-b | buffer | ||
M-x help Enter m | |||
Help | help | M-x help | help |
M-x help Enter k [key sequence] | key | ||
tutorial | M-x help Enter t | tutorial |
To learn more, visit Emacs Tour, Emacs Reference Manual, Emacs FAQ.
(setq frame-background-mode 'dark)
Save the file, exit emacs, and start it again.