These are for the combined vim-sexp
(https://github.com/guns/vim-sexp) and vim-sexp-mappings-for-regular-people
(https://github.com/tpope/vim-sexp-mappings-for-regular-people) plugins. vim-sexp
is neat on its own but Tim Pope makes common stuff much easier.
Note that some vim-sexp
functionality depends on <LocalLeader>
mappings. This is a different leader key than the global leader, and is the variable maplocalleader
(instead of mapleader
). To see if you have this set, use :echo maplocalleader
; if it errors out you'll need to set it, otherwise it will echo the key. If you want to set your LocalLeader
to <Space>
, you'll need two commands in your .vimrc
, since by default <Space>
is bound to <Right>
in normal mode:
nnoremap <Space> <Nop>
let maplocalleader=" "
- Movements
- Text objects
- Lispy actions
- Indenting
- Wrapping
- Splicing
(
and)
move to the nearest paired structural bracket;(
will take you backwards to the nearest(
,{
, or[
W
andB
move forwards/backwards element-wise within a form, ending on element heads: that is, if you're ona
in the outer form of(a (b c) d)
, you'll jump froma
to(
tod
when pressingWW
, versusww
which takes youa
=>(
=>b
E
andgE
move forwards/backwords element-wise, ending on tails:EE
on(a (b c) d)
takes youa
=>)
=>d
[[
and]]
move forwards/backwards between top-level elements:[[
on2
in(1 (a b)) (d (c d) 2)
will move you to the opening paren of1
[e
and]e
selects adjacent elements fowards/backwards<I
and>I
insert at the head/tail of a form
These are best used with the i
(inside) and a
(around) movements.
f
refers to the form under the cursor;if
when the cursor is onc
of(a (b c) d)
selectsb c
F
refers to the top-level form around the cursor;iF
onc
of(a (b c) d)
selectsa (b c) d
s
refers to stringse
refers to elements; in a word this means the word, on a parenthese this means the formw
refers to words, which are non-form elements; e.x. you cannotvif
from a parenthese
==
indents the current form=-
indents the top level form
<LocalLeader>i
and<LocalLeader>I
surround the current form with()
and places the cursor at the front (i
) or end (I
)<LocalLeader>[
and<LocalLeader>]
do the same things for[]
<LocalLeader>{
and<LocalLeader>}
do it for{}
<LocalLeader>w
and<LocalLeader>W
surround the current element with()
and place the cursor at the front/end<LocalLeader>e[
,<LocalLeader>e]
,<LocalLeader>e{
,<LocalLeader>e}
behave as above element-wise
<LocalLeader>@
splices the current form into its parent:(1 (2 3) 4)
=>(1 2 3 4)
<LocalLeader>o
replaces the parent form with the current form:o
in the middle of(1 (2 3) 4)
=>(2 3)
<LocalLeader>O
replaces the parent form with the current element:O
on2
in(1 (2 3) 4)
=>(1 2 4)
>f
and<f
swap or move the current form right/left (in the direction of the arrow):>f
on2
of(1 (2 3) 4)
=>(1 4 (2 3))
>e
and<e
move the current element right/left>)
and<(
slurp right/left; think of them like arrows moving the corresponding parentheses a direction:>)
in the inner form of(1 (2 3) 4)
=>(1 (2 3 4))
<)
and>(
burp right/left; again, the arrows are moving the parentheses:<)
in the inner form of(1 (2 3) 4)
=>(1 (2) 3 4)