Skip to content

Instantly share code, notes, and snippets.

@scottjbarr
Last active March 17, 2020 04:33
Show Gist options
  • Save scottjbarr/24c359735030948a589f to your computer and use it in GitHub Desktop.
Save scottjbarr/24c359735030948a589f to your computer and use it in GitHub Desktop.
Emacs Cheatsheet

Emacs Cheatsheet

C : Control key

M : Meta key

General

C-g - Exit command

C-x C-c - Quit Emacs

Navigation

C-l - Center the page on point

C-v - Move down a page

M-v - Move up a page

C-M-p - Scroll half a page up

C-M-n - Scroll half a page down

C-f - Move forward a character

C-b - Move backward a character

M-f - Move forward a word

M-b - Move backward a word

C-n - Move to next line

C-p - Move to previous line

C-a - Move to beginning of line

C-e - Move to end of line

M-a - Move back to beginning of sentence

M-e - Move forward to end of sentence

M-< - (META Less-than) Move to beginning of whole text

M-> - (META Greater-than) Move to end of whole

M-g M-g or M-g g - Go to line

C-u C-space or C-u C-@ - Jump back to previous point in current buffer

C-x C-space or C-x C-@ - Jump back to previous point in previous buffer

Editing

<DEL> - Delete the character just before the

C-d - Delete the next character after the

M-<DEL> - Kill the word immediately before the

M-d - Kill the next word after the cursor

C-k - Kill from the cursor position to end of line

M-k - Kill to the end of the current sentence

C-<SPC> - Mark start of region

C-w - Kill text in marked region

C-y - Yank text to current position

M-y - Yank text that was previously killed

C-/ - Undo

C-_ - Undo

C-x u - Undo

C-s - Search forward

C-r - Search reverse

C-s C-s - Repeat previous search forward

C-r C-r - Repeat previous search reverse

M-q or M-x fill-paragraph - Reindent paragraph (See http://www.emacswiki.org/emacs/FillParagraph)

Case

See https://www.gnu.org/software/emacs/manual/html_node/emacs/Case.html

M-l - Convert following word to lower case (downcase-word).

M-u - Convert following word to upper case (upcase-word).

M-c - Capitalize the following word (capitalize-word).

C-x C-l - Convert region to lower case (downcase-region).

C-x C-u - Convert region to upper case (upcase-region).

Selecting Text

C-x h - runs the command mark-whole-buffer

Indent

C-M-\ - runs the command indent-region

Files and Buffers

C-x C-b - List buffers

C-x C-f - Find file

C-x C-s - Save file

C-x k - Kill buffer

C-x s - Save some buffers

C-x C-b - List buffers

C-x b - Switch

C-x 1 - Delete all but one window

C-x 2 - Open 2nd window

C-x o - Switch to 'other' window

C-x d <Enter> - Open dired buffer in current location (or change the location before hitting Enter.

Modes

M-x mode - Switch to major mode, 'mode'

C-h m - Read documentation for current major mode

References

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