Emacs shortcuts


This is a quick reference guide to Emacs default keyboard shortcuts.

Introduction

For a better understanding of the following content, you should be familiar with how Emacs names some of the keyboard keys. Note that the keybindings mentioned here are for the Emacs editing style. Using evil changes the workflow, and you should look for Vim/Evil keybindings for more information. Also, if you are using an Emacs distribution or a custom configuration, some values may be different. Personally, I'm constantly shifting from Spacemacs (no evil mode) and Prelude. Yes, Spacemacs may be "heavier", but it has many useful features already loaded and ready to go. There's no such thing as better or worse. Use the one you like.

Commands are executed in a sequence and combination of different keyboard keys. The first key to press is a modifier key.

Whenever you see M as key1, it means META, and it corresponds to your keyboard ALT key.

Similarly, C as key1 is short for the CTRL (control) key. Also, S is SHIFT.

These keys are not used alone. They are combined with other key in what is called keybindings. A combination is represented by key1-key2, that means press and hold key1, press key2, release both keys.

Basic commands are executed in a sequence of keys, like key1-key2 key3, or key1-key2, key1+key3 - executed as press and hold key1, press key2, release both, press key3 or press and hold key1, press key3, release both.

Another important remark, commands are case sensitive.

I don't remember having M, C or S as a "last" press in a sequence, but if you come across it, it should be a capital letter, not the modifier key. There are commands using two modifiers at the same time. Ex.: C-M-\, or CTRL + ALT + \ (indent-region).

On that subject, some key-pressing is implicit and not described in commands. Example, to use the spellchecker on one word, the keybinding is M-$, or press and hold ALT and press $. Since this symbol usually requires pressing shift, the S press is implicit and not described in the command.

Help - C-h

Super useful!

What How Emacs terminology
What's this key C-h k Describe (press any keybinding to discover what it does!)
What's this keybinding C-h b Describe (press any keybinding to discover what it does!)
What's this command C-h a Apropos (type command name for more information)
Help C-h Help

Text (buffer) navigation

What How Emacs terminology
Home C-a beginning-of-lime
End C-e end-of-line
Down C-n next-line
Up C-p previous-line
Pg-Down C-M-n forward-list
Pg-U C-M-p backward-list
Sentence left M-a backward-sentence
Sentence right M-e forward-sentence
Word left M-b backward-word
Word right M-f forward-word
Char left C-b backward-char
Word right M-f forward-char
Paragraph up C-up backward-paragraph
Paragraph down C-down forward-paragraph
Previous element M-{ backward-element
Next element M-} forward-element
Go to line # M-g g goto-line
Go to char # M-g c goto-char
Go to start M-< beginning-of-buffer
Go to end M-> end-of-buffer
Search forward C-s isearch-forward
Search backward C-r isearch-backward

Text management

What How Emacs terminology
Select all text C-x h mark-whole-buffer
Start selection C-Space set-mark-command
Copy M-w kill-ring-save, but don't kill
Cut C-w kill-ring-save
Cut/copy+Cut/Copy C-M-w, M-w kill-ring-save, append to last kill
Delete line C-S-backspace kill-whole-line
Delete line forward C-k kill-line
Delete word forward M-d kill-word
Delete word backward M-Del / M-backspace backward-kill-word
Delete sentence forward M-k kill-sentence
Delete forward S-Delete kill-region
Paste C-y or S-insert yank
View clipboard C-x c M-y helm-show-kill-ring

Text transformation

What How Emacs terminology
Uppercase C-x C-u upcase-region
Uppercase forward M-u upcase-word
Lowercase forward M-l downcase-word
(Un)Comment line C-x C-; comment-line
Insert comment above M-; comment-dwin
Auto-correct previous word C-; flyspell-auto-correct-previous-word
Spellcheck current word M-$ ispell-word
Insert new line above C-o open-line

Undo - redo

What How Emacs terminology
Undo C-_ undo-tree
Redo M-_ undo-tree-redo
View the undo tree C-x u undo-tree-visualize

Window

What How Emacs terminology
Close file C-x k kill-buffer
List open files C-x b_ helm-buffers-list
Focus window frame (#) M-(#) winum-select-window-#
Close active window frame C-x 0 or q delete-window
Maximize current file C-x 1 maximize-buffer
New horizontal window frame C-x 2 split-window-below
New vertical window frame C-x 3 split-window-right
New "window" (frame) C-x 5 2 make-frame
Close "window (frame) C-x 5 0 delete-frame
Close other "windows" C-x 5 1 delete-other-frames
Quit Emacs C-x C-c save-buffers-kill-terminal

File

What How Emacs terminology
Open a file C-x C-f find-file
Open Treemacs M-0 treemacs-select-window
Save C-x C-S save-buffer
Save as C-x C-w ido-write-file