Skip to content

Instantly share code, notes, and snippets.

@erdg
Last active December 30, 2021 02:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erdg/fa263802cc7c1b3d6cbc9398e5a86b5e to your computer and use it in GitHub Desktop.
Save erdg/fa263802cc7c1b3d6cbc9398e5a86b5e to your computer and use it in GitHub Desktop.
Cheatsheet for viprc
# ^ or ## - search word under cursor backwards ('#' is masked)
#
# F - move to first non-space char of next line
# H - go to first non-space char, then (press again) jump indentation level up/left
# L - go to end of lisp line, then (press again) end of line
# T - move to next opening paren
# U - undo lisp cut (append current line to end of previous line)
# V - lisp cut (move rest of line to new line below)
# [ - like '{', but goes to first char of paragraph
# ] - like '}', but goes to first char of paragraph
# ^L - indent paragraph, set mark "@"
# ^N - insert empty line below current line
# ^P - insert empty line above current line
#
# ( - prefix for opening forms
# (( - insert single '('
# (> - move paren right (barf)
# (< - move paren left (slurp)
# ($ or (. - wrap to end of line, insert at beginning
# (i - wrap element (atom or list), insert at beginning
# (a - wrap element, insert at end
# (o - insert form below current line
# (O - insert form above current line
# (& - wrap element with 'and', insert at end
# (| - wrap element with 'or', insert at end
# () - wrap form
# (` - wrap parent form
# (, - wrap all child forms
# (* - wrap all forms (at same indentation)
# (/ - wrap form and all forms above (at same indentation)
# (\ - wrap form and all forms below (at same indentation)
# (_ or (0 - insert form as last (at same indentation)
#
# ) - prefix for closing forms
# )) - insert single ')'
# )> - move paren right (slurp)
# )< - move paren left (barf)
# )! or )0 - remove trailing parens on line
# )$ or ). - close parens on line
# N)~ or ), - close all but N parens on line (default 1)
# N)` - close parens on current line and up N levels
# )? - close parens to search backwards
# )' - close parens to first quote on line
# N)+ - add N parens to end of line
# N)- - remove N parens from end of line
# )} - indent and close all parens (at end of paragraph)
#
# @ - prefix for moving / refactoring forms
# @w - move element forward on line
# @j - move form down (at same indentation)
# @k - move form up (at same indentation)
# N@y or @Y - yank (N) form(s at same indentation)
# @p - paste form(s) below current line
# @P - paste form(s) above current line
# @~ - splice element / form (remove surrounding parens)
# @` - expand form to wrap surrounding form ("convolute" from paredit)
# @? - refactor (multi-line) 'if' (with else clause) to 'cond'
#
# @! - prefix for killing forms
# N@!! - kill (N) form(s at same indentation)
# @!` - splice killing backwards
# @!~ - kill form, splicing children
# @!* - kill all forms at same indentation
# @!/ - kill all forms above at same indentation
# @!\ - kill current form and all forms below at same indentation
#
# # - prefix for comments
# ## - search word under cursor backwards
# #~ or #. - toggle leading '#' on (N) line(s)
# #$ - (re)write end of line comment
# #! - delete end of line comment (paste comment with '$p')
# #^ - move end of line comment to new line above
# #@ - remove surrounding comment wrap
# #' - comment wrap element
# #% - comment wrap to matching paren
# #* - comment wrap all forms at same indentation
# #/ - comment wrap all forms above current form at same indentation
# #\ - comment wrap current form and all forms below at same indentation
# #} - comment wrap paragraph forward (wax on)
# #{ - uncomment paragraph backward (wax off)
# #] - comment paragraph forward block-style (wax on)
# #[ - uncomment paragraph backward block-style (wax off)
#
# grc - edit viprc
# gre - reload viprc
#
# lisp mode (balanced parens, auto-indent, etc)
# gi - insert
# gI - insert at beginning of line
# ga - append
# gA - append to end of line
# go - open new line below current line
# gO - open new line above current line
#
# g' - insert quote from normal mode
# g<space> - insert space to left of cursor
#
# additional lisp motions
# gj - move down expr at same indentation
# gk - move up expr at same indentation
# gl - move in to next indentation level with multiple forms
# g1 to g8 - move to Nth form at same indentation
# g9 - move to penultimate form at same indentation
# g0 - move to last form at same indentation
# g) - move to next end of multi-line form
#
# gh - view docs for word under cursor
# g? - view docs for this viprc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment