Skip to content

Instantly share code, notes, and snippets.

@buggtb
Forked from heroheman/spacemacs-cheatsheet.md
Last active December 14, 2022 22:30
Show Gist options
  • Save buggtb/e1b88af8fe47347f7e02d1653205dcbd to your computer and use it in GitHub Desktop.
Save buggtb/e1b88af8fe47347f7e02d1653205dcbd to your computer and use it in GitHub Desktop.
Spacemacs Cheatsheet - A cheat sheet for my most common shortcuts in Spacemacs

General

Shortcut Description
SPC f e d Open Configuration
SPC f e R Reload Configuration
SPC SPC Search Emacs
SPC h SPC Search Spacemacs Layer
SPC f s Save Buffer
SPC q q Quit Emacs w/ Prompt
SPC q Q Quit Emacs w/o Prompt
SPC f t Toggle NeoTree
SPC TAB Switch window to previous buffer
SPC ? Search for Keybinding

Window Management SPC w

Shortcut Description
SPC w / Vertical Split Window
SPC w - Horizontal Split Window
SPC w d Delete Window
SPC w 2 Layout Double Columns
SPC w 3 Layout Triple Columns
SPC w h/j/k/l Window Navigation
SPC w = Balance Windows
SPC w m toggle maximize window

File Management SPC f

Shortcut Description
SPC f s Save buffer
SPC f S Save all open buffer
SPC f f Find file
SPC f t Show NeoTree Fileexplorer
SPC f R Rename current buffer

Buffer Management SPC b

Shortcut Description
SPC b b list open buffer; show actions with CTRL z
SPC b d kill current buffer
SPC b p previous buffer
SPC b n next buffer

Project Management SPC p

Shortcut Description
SPC p p Search Projects
SPC p f Search in Project
SPC p h Search in Project and open buffers

Helm Lists

Shortcut Description
CTRL k Down
CTRL j Up
CTRL h parent folder (in file view)
CTRL SPC Mark File
CTRL z Open action menu

Web Mode

see: https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/html

General

Shortcut Description
SPC m g p quickly navigate CSS rules using helm
SPC m e h highlight DOM errors
SPC m g b go to the beginning of current element
SPC m g c go to the first child element
SPC m g p go to the parent element
SPC m g s go to next sibling
SPC m h p show xpath of the current element
SPC m r c clone the current element
SPC m r d delete the current element (does not delete the children)
SPC m r r rename current element
SPC m r w wrap current element
SPC m z fold/unfold current element
% evil-matchit keybinding to jump to closing tag
SPC m . Transient state with further actions

Javascript

see: https://github.com/syl20bnr/spacemacs/tree/master/layers/%2Blang/javascript

JS Refactoring

Shortcut Description
SPC m w toggle js2-mode warnings and errors
SPC m r 3 i converts ternary operator to if-statement
SPC m r c a converts a multiline array to one line
SPC m r e a converts a one line array to multiline
SPC m r c o converts a multiline object literal to one line
SPC m r e o converts a one line object literal to multiline
SPC m r l t adds a console.log statement for what is at point (or region)
SPC m r s s splits a string
SPC m x m j move line down, while keeping commas correctly placed
SPC m x m k move line up, while keeping commas correctly placed

Tern

Shortcut Description
SPC m C-g brings you back to last place you were when you pressed M-..
SPC m g g jump to the definition of the thing under the cursor
SPC m g G jump to definition for the given name
SPC m h d find docs of the thing under the cursor. Press again to open the associated URL (if any)
SPC m h t find the type of the thing under the cursor
SPC m r r V rename variable under the cursor using tern

JS Doc

Shortcut Description
SPC m r d b insert JSDoc comment for current file
SPC m r d f insert JSDoc comment for function
SPC m r d t insert tag to comment
SPC m r d h show list of available jsdoc tags

GIT

Shortcut Description
SPC g s open a magit status window
SPC g S stage current file
SPC g M display the last commit message of the current line in popup
SPC g t launch the git time machine
SPC g U unstage current file
SPC m g f U show commits from current file

Golang

Shortcut Description
SPC m = run "go fmt"
SPC m e b go-play buffer
SPC m e d download go-play snippet
SPC m e r go-play region
SPC m g a jump to matching test file or back from test to code file
SPC m g c open a clone of the current buffer with a coverage info (go tool cover -h for help)
SPC m g g go jump to definition
SPC m h h godoc at point
SPC m i a add import
SPC m i g goto imports
SPC m i r remove unused import
SPC m r n go rename
SPC m t P run "go test" for the current package and all packages under it
SPC m t g f generate tests for all exported functions
SPC m t g F generate tests for all functions
SPC m t g g DWIM generate test for the function in the active region
SPC m t p run "go test" for the current package
SPC m t s run "go test" for the suite you're currently in (requires gocheck)
SPC m t t run "go test" for the function you're currently in (while you're in a _.test.go file)
SPC m x x run "go run" for the current 'main' package

Go Guru

Shortcut Description
SPC m f < go-guru show possible callers
SPC m f > go-guru show call targets
SPC m f c go-guru show channel sends/receives
SPC m f d go-guru describe symbol at point
SPC m f e go-guru show possible contants/types for error value
SPC m f f go-guru show free variables
SPC m f i go-guru show implements relation
SPC m f j go-guru jump to symbol definition
SPC m f o go-guru set analysis scope
SPC m f p go-guru show what the select expression points to
SPC m f r go-guru show referrers
SPC m f s go-guru show callstack

Go Refactoring

Shortcut Description
SPC m r d Add comment stubs
SPC m r e Extract code as new function
SPC m r f Add field tags (with gomodifytags)
SPC m r F Remove field tags (with gomodifytags)
SPC m r i Generate method stubs for implementing an interface (go-impl)
SPC m r n Rename (with godoctor)
SPC m r N Rename (with go-rename)
SPC m r s Fill structure with default values (with go-fillstruct)
SPC m r t Toggle declaration and assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment