Skip to content

Instantly share code, notes, and snippets.

@pvik
Last active April 24, 2023 01:13
  • Star 58 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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
@Fuco1
Copy link

Fuco1 commented Sep 10, 2018

Would love this somewhere in smartparens wiki or readme. Open an issue and we can figure out the details! Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment