C | followed by a “-” and a letter means hold down the <CONTROL> key while pressing the appropriate letter. |
M | followed by a “-” and a letter means hold down the <META> key (diamond on the Sun keyboard - not the <ALT> key); on keyboards without an <ALT> or <META> key, it means depress and release the <ESC> key followed by the appropriate letter. |
Session |
|
C-x C-c |
exit emacs |
C-x C-s |
save a file back to disk |
! |
execute a shell command |
| |
run a shell command on region |
C-u | |
filter a region through a shell command |
Search |
|
C-s string |
search forward for “string” |
C-s |
repeat previous search forward |
C-r string |
search backward for “string” |
C-r |
repeat previous search backward |
C- s string |
regular expression search for r.e. “string” |
<ESC> | or
escape incremental search (any command escapes) |
<ENTER> |
set string mark to the point where cursor had been before the search |
Cut/Copy/Paste, Mark | |
“Marking” sets a stake in the sand. A region to be cut or copied comprises the text between the mark and the cursor (point). |
|
C-@ or C-<SPC> |
set mark here |
C-x C-x |
exchange point and mark |
w |
copy |
C-w |
cut |
C-y |
paste (“yank”) |
Delete and Kill | |
“Deleting” merely removes the text, “Killing” also copies it to the paste buffer |
|
<DEL> |
delete backward one character |
C-d |
delete forward one character |
<DEL> |
delete backward one word |
d |
delete forward one word |
c (char) | z
kill to next occurrence of character “c” |
C-k |
kill to end of line |
C-y |
yank back last thing killed (“paste”) |
Replace | |
% |
interactively replace a test string |
replace-string | x
replace string with string mark to end of file |
Cursor Movement | |
C-f |
forward one character |
C-b |
backward one character |
C-n |
to next line |
C-p |
to previous line |
f |
forward one word |
b |
backword one word |
C-a |
to beginning of line |
C-e |
to end of line |
n | r
cursor to line n of screen |
< |
to beginning of file |
> |
to end of file |
C-v |
forward one screen |
v |
backward one screen |
C-<UP-ARROW> |
up one paragraph |
C-<DOWN-ARROW> |
down one paragraph |
Numeric Arguments |
|
Some commands have a numeric argument, typically a “repeat count”, “distance” measure or line number. These are specified with a numeric prefix, multiple digits and negative numbers permitted. Negative numbers typically denote movement in the opposite direction. |
|
0..9 |
numeric argument (denoted herein as n) |
C-u 0..9 |
numeric argument (denoted herein as n) |
Scroll Screen | |
n C-v |
move forward n lines (scroll up) |
n | v
move backward n lines (scroll down) |
C-l |
scroll current line to center of screen |
n C-l |
scroll current line to line n of screen |
Error Recovery |
|
C-x u or C-_ |
undo last command |
C-g |
abort partially typed or executing command |
C-l |
redraw garbled screen |
revert-buffer | x
restore a buffer to its original contents |
recover-file | x
recover a file lost by a system crash |
Files |
|
C-x C-f |
read a file into emacs |
C-x C-s |
save a file back to disk |
C-x i |
insert contents of another file into this buffer |
C-x C-v |
replace this file with the contents of file you want |
C-x C-w |
write buffer to specified file |
Getting Help | |
C-\ t |
Tutorial recommended for new emacs users |
C-x 1 |
get rid of help window |
C- v |
scroll help window |
General |
|
C-\ t |
Tutorial suggested for new emacs users. |
C-x C-c |
exit emacs |
C-h k key |
describe meaning of key “key” |
- u |
convert previous word to Upper case |
- l |
convert previous word to Lower case |
- c |
convert previous word to initial Capital case |
Multiple Windows | |
C-x 1 |
delete all other windows |
C-x 0 |
delete this window |
C-x 2 |
split this window in half vertically |
C-x 5 |
split this window in half horizontally |
C- v |
scroll other window |
C-x o |
switch cursor to another window |
Buffers | |
C-x b |
select another buffer |
C-x b bname |
create a buffer named “bname” |
C-x C-b |
list all buffers |
C-x k |
kill a buffer |
Spelling Check | |
$ |
check spelling of current word |
spell-region | x
check spelling of marked region |
spell-buffer | x
check spelling of entire buffer |
Additional help is available in man emacs.
(adapted from: http://vertigo.hsrl.rutgers.edu/ug/emacs_qref.html)