I'm really liking my first impressions of vim-sexp. It's like paredit minus a couple of parts of paredit that are impossibly tricky to implement in Vim. I'm not too keen on some of the default mappings, though, and in particular the mappings using the meta key are just an absolute deal breaker for me and everyone else that uses Vim in a terminal. So I made and published my own, in an attempt to define a more accessible standard.
You know the drill. Here's a copy and paste to install the works with pathogen.vim.
cd ~/.vim/bundle
git clone git://github.com/tpope/vim-sexp-mappings-for-regular-people.git
git clone git://github.com/guns/vim-sexp.git
git clone git://github.com/tpope/vim-repeat.git
git clone git://github.com/tpope/vim-surround.git
These mappings supplement rather than replace the existing mappings (despite vim-sexp's best efforts to thwart this), so if you have muscle memory, fear not.
Vim-sexp uses meta mappings to move element-wise. I've taken over the WORD
motions--W
, B
, E
, gE
--instead, operating under the theory that those
aren't nearly as useful in a language where so many punctuation marks are
identifier characters. This might be a terrible idea.
More meta madness in the defaults here. I've taken >f
and <f
to move a
form and >e
and <e
to move an element.
Slurpage and barfage are handled by >)
, <)
, >(
, and <(
, where the
angle bracket indicates the direction, and the parenthesis indicates which end
to operate on.
Use <I
and >I
to insert at the beginning and ending of a form.
Note that surround.vim out of the box works great with the sexp.vim motions
and text objects. Use ysaf)
, for example, to surround the current form with
parentheses. To this, we add a few more mappings:
dsf
: splice (delete surroundings of form)cse(
/cse)
/cseb
: surround element in parenthesescse[
/cse]
: surround element in bracketscse{
/cse}
: surround element in braces
Copyright © Tim Pope. Distributed under the same terms as Vim itself.
See :help license
.