On Sun 24 Nov 2013 at 10:11:59PM +0300, Chris Ford wrote:
> Hi all,
>
> I regularly refactor Clojure forms and then tidy them with *=ip*. This
> works great for handling indentation, but there's one thing that it misses
> that keeps catching me out.
>
> Following what I believe to be good Clojure style, this...
>
> (defn foo [x]
> (+ x 1)
> )
>
> should become...
>
> (defn foo [x]
> (+ x 1))
>
> Is there any way to tidy up trailing parentheses? Is there a command other
> than *= *I should be using?
People generally use plugins that offer balanced bracket insertion such
as paredit.vim or vim-sexp¹.
It sounds like you might like the "electric-return" feature from
paredit.vim.
If you just want to manually join the bracket on the next line, you can
always use vim's join-lines command: J
Unfortunately, Vim unhelpfully adds a space when joining ] and }. There
may be a plugin to fix that, but I opted to patch vim instead. (patch
attached)
HTH
guns
¹ This is an S-Expression plugin that I wrote earlier in the year. It
differs philosophically from paredit.vim (text objects vs. emacs style
editing), but they both offer balanced bracket insertion for Clojure.