Emacs keybindings I use

Preliminaries

The most important shortcut to know is SPC :, which allows you to run any emacs command. If you want to find out which function a particular shortcut invokes, use SPC h k followed by that shortcut. For the obverse—to find out the shortcut (and documentaion) for a particular function—use SPC h f.

Files & Buffers

Open a file:

Manage buffers:

  • SPC b b - Switch between open buffers
  • SPC b s - Save the active buffer
  • SPC b k - Kill (i.e., close) the active buffer
  • SPC b l - Switch to the last buffer
  • SPC s p - Search across all files in the project
  • SPC s s - Search the active buffer

Layout

Window management

Workspace management

Think of emacs workspaces as “virtual desktops”.

Project

  • SPC p f or SPC SPC - Open a file in the project
  • SPC o P - Open a file in the project, using the project sidebar
  • SPC o p - Show / Hide the project sidebar

Git

doom-emacs uses magit. SPC g g brings the magit-status buffer. The following shortcuts work on this buffer:

  • s - Stage the selected file(s) or hunk
  • u - Unstage the selected file(s) or hunk
  • TAB - View/Hide the diff of a selected file
  • c c - Commit the staged changes
  • p p - Push commits to remote repository
  • d r - Diff range (eg: to view changes in current branch)

Code navigation

See also: tools/lookup

  • g; - Go to last change
  • SPC s i - Go to a symbol (eg: function) in current buffer
  • SPC c D (or gD) - See a list of references for the symbol at point from throughout your project

Editing

Visual mode

After having selected some text:

  • S* - Surround selection with ‘*
Created on: