Sei sulla pagina 1di 2

Emacs

Cheat Sheet


Emacs uses two keys for special sequences Control (Ctrl) and Meta. The
Meta key is usually the alt key. Mac users have to configure their terminal specially
for this. Mac users should also note that Control is different from Command.

Youll find patterns in the key strokes: in general, a command with Ctrl and
one with Meta will be related. For example, Ctrl-v scrolls down, Meta-v scrolls up.
Ctrl-w cuts, Meta-w copies.

SAVE AND CLOSE
Sequence
Mnemonic
Action
Ctrl-x Ctrl-s
save
Save file.
Ctrl-x Ctrl-c
close
Close emacs. It will prompt you to save if you
have unsaved changes.
Ctrl-z

Suspend emacs and go back to terminal. To
bring back that emacs session, use the fg
command in terminal.


NAVIGATION
Sequence
Mnemonic
Action
Ctrl-v
V points down Scroll down one screenful.
Meta-v

Scroll up one screenful.
Ctrl-a
a starts the
Move to the start of the current line.
alphabet
Ctrl-e
end
Move to the end of the current line.
Meta-<
< points to
Move to the beginning of the file.
beginning
Meta->
> points to the Move to the end of the file.
end
Meta-arrow key

Move the cursor one word instead of a
character.
Ctrl-l (el)

Center screen around the cursor.



DELETE, CUT, COPY, PASTE
Sequence
Mnemonic
Action
Ctrl-d
delete
Delete the next character.
Ctrl-k
kill
Cut from the cursor until the end of the line.
Ctrl-space

Begin selecting a region.
Ctrl-w
W looks like
Cut the current selection.
scissors
Meta-w

Copy the current selection.
Ctrl-y
yank
Paste at the current position.
Meta-y

Change what you pasted to move farther back
in the clipboard.


CONTROL
Sequence
Mnemonic
Ctrl-_ (underscore) Underscore
Ctrl-u

Ctrl-g

get me out of
here

Action
Undo.
Repeat. After Ctrl-u, type a number, then a
command or letter to repeat.
Exit a command that youve started.



BUFFERS
A buffer is like a tab. Its how you keep and switch between multiple files.
Sequence
Mnemonic
Action
Ctrl-x Ctrl-f
file
Open or create a file.
Ctrl-x Ctrl-b
buffer
Look at all open buffers. (Ctrl-x 1 to exit).
Ctrl-x b

Switch to buffer. Type buffer name.
Ctrl-x s
save
Save each open buffer.


WINDOWS
In emacs, you can look at multiple files (or the same file) side-by-side. Only one can
be in focus at a time (the one youre typing in).
Sequence
Mnemonic
Action
Ctrl-x 1 (one)
Leave 1 open
Close all open windows except the one in focus.
Ctrl-x 2
Make 2
Split current window into two (horizontally).
windows
Ctrl-x 3

Split current window into two (vertically).
Ctrl-x o
other
Change focus to the other open window.

MISC.
Sequence
Mnemonic
Action
Ctrl-s
search
Search forwards. After Ctrl-s, type the word to
search. Hit Ctrl-s to move to the next match.
Press backspace to go back one match.
Ctrl-r
reverse
Search backwards. Otherwise same as Ctrl-s.
Meta-%

Find and replace. Type string to find, hit enter.
String to replace, enter. Press space to replace
current selection; backspace to not; enter to
finish replacing.

HELP
To get help on a command, type Ctrl-h k then a command to look up.
To search for a command, Ctrl-h a then a string to search for.

PRACTICE
To get more practice, open emacs and type Ctrl-h t. This opens a tutorial, which
takes 12 hours to complete (you dont have to do it all at once).

Potrebbero piacerti anche