Skip to content

Instantly share code, notes, and snippets.

@cribeiro
Last active November 12, 2016 23:09
Show Gist options
  • Save cribeiro/4a10cf13cd789bb17aa511c263b62a65 to your computer and use it in GitHub Desktop.
Save cribeiro/4a10cf13cd789bb17aa511c263b62a65 to your computer and use it in GitHub Desktop.
Emacs Survival Guide

Emacs Survival Guide

Notation

C for Control key (also labeled as CTL or CTRL on keyboards)

M for Meta key (also labeled as EDIT, ALT or COMMAND on keyboards)

if your keyboard doesn't have this key, just press and release ESC for the same purpose.

C-<chr> means hold the Control key while typing the key chr.

M-<chr> means hold the Meta key while typing the key char.

M-<chr1> M-<chr2> means doing M-<chr> twice.

you could instead of hitting 4 keystrokes, just press Meta key while typing chr1 first and chr2 after.

DEL means, on most popular keyboard, the backspace key (not the delete itself).

Navigation

C-v view next screen

v for arrow down side

M-v view previous screen

C-l clear the screen and centralize the page around the cursor.

repeat once to put the cursor on bottom and twice to put it on top.

C-p move cursor to previous line

C-n move cursor to next line

C-b move cursor one char backward

C-f move cursor one char forward

M-f move cursor one word forward

M-b move cursor one word backward

C-a move cursor to the beginning of the line (remember that a is the very first letter of the Latin alphabet).

C-e move cursor to the end of the line.

M-a move cursor to the beginning of the sentence

M-e move cursor to the end of the sentence

M-< move cursor to the beginner of the text

< for arrow left side

M-> move cursor to the end of text

> for arrow right side

Deleting

DEL delete a char before cursor

C-d delete a char after cursor

M-DEL kill the word right before the cursor

M-d delete the word right after the cursor

C-k kill from the current cursor position until the end of the line

M-k kill from the current cursor position until the end of the sentence

Files & buffers

C-x C-f find a file

C-x C-s save the file

C-x C-b list buffers

C-x b switch buffer

C-x s ask for each changed buffers whether to save it or not

Windows

C-x 1 closes all windows other than the current one

C-x 2 split the current window in two horizontal ones

C-x 3 split the current window in two vertical ones

C-x o change to other window

C-x 0 close the current window

C-M-v scroll the other window

Misc

C-u n command mostly repeat command n times.

you could shortly type M-n command

C-g escape or exit any current command

C-SPC navigation-command mark a region, usually to be killed or deleted

C-y yank back (reinsert) the killed text

C-x u undo the last command. The same as C-_.

most shortly, you could type C-/ for the same purpose.

C-x C-c close Emacs session

C-s search forward C-r reverse search, i.e., search backward

Help

C-h ? ask for help in a generic sense

C-h c command ask for a brief help for command. Ex.: C-h c C-p shows "C-p runs the command previous-line"

C-h k command get more details about command

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment