Skip to content

Instantly share code, notes, and snippets.

@pvik
Last active December 16, 2024 17:54
Show Gist options
  • Save pvik/8eb5755cc34da0226e3fc23a320a3c95 to your computer and use it in GitHub Desktop.
Save pvik/8eb5755cc34da0226e3fc23a320a3c95 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
@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