Spacemacs cheat sheet

Reference commands for the spacemacs text editor.
  1. Modifier keys
    1. Other common keys
  2. General commands
    1. Find and replace
    2. Toggle settings
    3. Fill to right margin
  3. Layers (plugins)
    1. Git
      1. Common commands
      2. Bindings inside status buffer
      3. Staging lines
      4. Commit message editing buffer
      5. Interactive rebase buffer
      6. Time machine
      7. Quick guide for recurring use cases in Magit
    2. ESS
      1. Key bindings
      2. Helpers
    3. TRAMP
    4. unimpaired
    5. evil-mc
    6. eyebrowse
  4. Troubleshooting
  5. References

Modifier keys

These are used frequently in Emacs documentation.

Emacs Meaning Keystroke
C Control Ctrl
M Meta Esc; Alt/Option

Here are some examples showing how these modifiers are used in documentation, and how they map to keystrokes:

Other common keys

Emacs Meaning Keystroke
ALT Alt Alt
BS Backspace Backspace, C-h
CTRL Control Ctrl
DEL Delete Delete
LFD Line feed C-j
RET Return Return, Enter, C-m
SPC Spacebar Space
TAB Tab Tab

This guide on how keystrokes are denoted in Emacs is a useful reference.

General commands

Find and replace

Toggle settings

Fill to right margin

Use M-q to automatically fill paragraphs to fill-column value. Refer to turn-on-fci-mode, fill-column for details.

Layers (plugins)

Git

Spacemacs uses Magit by default to manage Git repositories.

Spacemacs uses evil-magit for key bindings in magit buffers (unless your editing style is set to emacs, in which case you get the default magit bindings), which are the standard magit key bindings with some minimal changes to make them comfortable for evil users.

Highlight by age of commit or last update time is provided by smeargle. Git time machine is provided by git-timemachine. Git last commit message per line is provided by git-messenger.

Common commands

Bindings inside status buffer

Staging lines

Magit allows you to stage specific lines by selecting them in a diff and hitting s to stage. Due to inconsistencies between Vim and Emacs editing styles, if you enter visual line state with V, you will stage one more line than intended. To work around this, you can use v instead (since Magit only stages whole lines, in any case).

Commit message editing buffer

Interactive rebase buffer

Time machine

git-timemachine allows to quickly browse the commits of the current buffer.

Quick guide for recurring use cases in Magit

Amend a commit:

  1. l l: Open the log buffer.
  2. c a: Amend the commit.
  3. ~,c~; C-c C-c: Submit the changes.

Squash last commit:

  1. l l: Open the log buffer.
  2. r e on the second to last commit; it opens the rebase buffer.
  3. j: Put point on last commit.
  4. s: Squash it.
  5. ~,c~; C-c C-c: Continue to the commit message buffer.
  6. ~,c~; C-c C-c (again): Edit the commit message.

Add upstream remote (the parent repository you have forked):

  1. M: Open the remote popup.
  2. a: Add a remote, type the name (i.e. upstream) and the URL.

Pull changes from upstream (the parent repository you have forked) and push:

  1. F -r C-u F: Choose upstream or the name you gave to it.
  2. P P: Push the commit to origin.

ESS

Emacs speaks statistics (ESS) is an incredibly useful interface for R programming on a remote server where RStudio is not available.

The Emacs documentation frequently refers to REPL, which stands for read-eval-print loop. You’ll see this in the ESS documentation for spacemacs.

command action
M-x R Launch ESS / R
M-x ess-version Check ESS version

The standard Ctrl+Enter console command will work when ESS major-mode keybindings are defined. Note that this might not be configured properly for spacemacs on a fresh install.

Switch between console and source code windows using M-1 here. Note that SPC 1 doesn’t work when focused on the R console.

Key bindings

Send code to an inferior REPL process with these commands:

Key binding Description
SPC m c c send knitr/sweave chunk and keep buffer focused
SPC m c C send knitr/sweave chunk and switch to REPL in insert mode
SPC m c d send knitr/sweave chunk and step to next chunk
SPC m c m mark knitr/sweave chunk around point
SPC m c n next knitr/sweave chunk
SPC m c N previous knitr/sweave chunk
SPC m s b send buffer and keep code buffer focused
SPC m s B send buffer and switch to REPL in insert mode
SPC m s d send region or line and step (debug)
SPC m s D send function or paragraph and step (debug)
SPC m s i start an inferior REPL process
SPC m s l send line and keep code buffer focused
SPC m s L send line and switch to REPL in insert mode
SPC m s r send region and keep code buffer focused
SPC m s R send region and switch to REPL in insert mode
SPC m s t send thing at point (function) and keep code buffer focused
SPC m s T send thing at point (function) and switch to REPL in insert mode
C-j next item in REPL history
C-k previous item in REPL history

Helpers

Helpers for inspecting objects at point are available in R buffers only.

Key binding Description
SPC m h d View data under point using ess-R-data-view
SPC m h t View table using ess-R-data-view

Refer to the ESS layer documentation for more information.

TRAMP

TRAMP is a very useful package for editing remote files over SSH from within a local emacs instance. Drowzy’s Medium post has useful additional details.

unimpaired

Pairs of handy bracket mappings with unimpaired.

Note that spacemacs contains an internal port of unimpaired.

evil-mc

evil-mc enables the use of multiple cursors.

eyebrowse

eyebrowse is a workspace manager.

Troubleshooting

Fix for org-projectile warning:

Error (use-package): org-projectile/:config: Symbol’s function definition is
void: org-projectile:per-repo
rm -fv ~/.emacs.d/elpa/org-projectile-*/org-projectile.elc

References

Configurations:

See also: