Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jsmestad
Forked from pvik/smartparens-cheatsheet.md
Created September 9, 2018 00:19
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jsmestad/1059d15e8debf5f2e7e81c92052c67d2 to your computer and use it in GitHub Desktop.
Save jsmestad/1059d15e8debf5f2e7e81c92052c67d2 to your computer and use it in GitHub Desktop.
A Cheatsheet for Emacs Smarparens example configuration

An animated cheatsheet for smartparens using the example configuration specified here by the smartparens author. Inspired by this tutorial for paredit.

Traversal

C-M-f sp-forward-sexp
C-M-b sp-backward-sexp
C-M-d sp-down-sexp
C-M-u sp-backward-up-sexp
C-M-a sp-backward-down-sexp
C-M-e sp-up-sexp

Wrap & Unwrap

I have the following set to make wrapping sexps a little easier.

(define-key smartparens-mode-map (kbd "M-(") 'sp-wrap-round)
(define-key smartparens-mode-map (kbd "M-[") 'sp-wrap-square)
(define-key smartparens-mode-map (kbd "M-{") 'sp-wrap-curly)
M-( sp-wrap-round
M-[ sp-wrap-square
M-{ sp-wrap-curly
M-[delete] sp-unwrap-sexp
M-[backspace] sp-backward-unwrap-sexp

Slurping & Barfing

C-[right] sp-forward-slurp-sexp
C-[left] sp-forward-barf-sexp
C-M-[right] sp-backward-slurp-sexp
C-M-[left] sp-backward-barf-sexp

Splicing

C-M-[delete] sp-splice-sexp-killing-forward
C-M-[backspace] sp-splice-sexp-killing-backward

Complete Table

Keybinding Command
C-M-f sp-forward-sexp
C-M-f sp-backward-exp
C-M-d sp-down-sexp
C-M-f sp-forward-sexp
C-M-b sp-backward-sexp
C-M-d sp-down-sexp
C-M-a sp-backward-down-sexp
C-S-d sp-beginning-of-sexp
C-S-a sp-end-of-sexp
C-M-e sp-up-sexp
C-M-u sp-backward-up-sexp
C-M-t sp-transpose-sexp
C-M-n sp-forward-hybrid-sexp
C-M-p sp-backward-hybrid-sexp
C-M-k sp-kill-sexp
C-M-w sp-copy-sexp
M-<delete> sp-unwrap-sexp
M-<backspace> sp-backward-unwrap-sexp
C-<right> sp-forward-slurp-sexp
C-<left> sp-forward-barf-sexp
C-M-<left> sp-backward-slurp-sexp
C-M-<right> sp-backward-barf-sexp
M-D sp-splice-sexp
C-M-<del> sp-splice-sexp-killing-forward
C-M-<backspace> sp-splice-sexp-killing-backward
C-S-<backspace> sp-splice-sexp-killing-around
C-] sp-select-next-thing-exchange
C-<left_bracket> sp-select-previous-thing
C-M-] sp-select-next-thing
M-F sp-forward-symbol
M-B sp-backward-symbol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment