Emacs Cheat Sheet


Master doc: http://www.gnu.org/software/emacs/tour/

exit: C-x C-c
rum emacs in terminal mode (no X): emacs -nw
quit from a command: C-g
gdb: M-x gdb
diff: M-x ediff
dir browsing: M-x dired
switch to dir edit mode:  C-x C-q
news/rss/email: M-x gnus
tetris: M-x tetris
tutorial: C-h t
shell command: M-!
switch between widnows: C-x o
switch to previous buffer: C-x b

forward one word: M-f
back one word: M-b
previous sentence: M-a
next sentence: M-e
beginning of buffer: M-<
end of buffer: M->
jump to specific line: M-g g
search forward: C-s
search backward: C-r

mark: C-SPC
note: some command set mark for you automatically: yank, kill, search, …
swap point and mark: C-x C-x
cycle through mark ring: C-u C-SPC

As you can see, Emacs tries to be helpful: many commands that have the potential to take you long distances set mark so that a simple C-x C-x takes you back to where you were.

start highlight: C-SPC
select all: C-x h
select current paragraph: M-h
copy higlighted section: ESC w
kill to end of line: C-k
kill to end of sentence: M-k
kill 10 lines: C-u 10 C-k
kill next word: M-d
kill to end of sentence: M-k
kill region (“cut”): C-w
note: there is a kill ring too, so it is so difficult to lose data 😉
save region to kill ring without deleting (“copy”): M-w
yank: C-y
replace yanked text with previously killed text: M-y

Narrow buffer to the current region: C-x n n
Restore (“widen”) buffer: C-x n w

Narrowing restricts the view (and editing) of a buffer to a certain region. Then commands like incremental search, or beginning-of-buffer or end-of-buffer don’t lead you out of the region of interest, and commands like search and replacement don’t affect the entire file.

Undo: there are 3 commands for undo:
C-x u

After any consecutive sequence of undos, Emacs makes all your previous actions undoable, including the undos. (This will happen whenever a sequence of undos is broken by any other command.)

If this sounds complicated, just remember that “undo” is always capable of getting you back to any previous state your buffer was in (unless Emacs has run out of memory to store the undo history). The principle here is that Emacs makes it very difficult to accidentally lose your work.

code autocompletion: M-/
code autodocumentation: M-;



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s