vimparedit

paredit.vim move inner list out of enclosing list


I'm using Vim to edit Clojure code and I'm giving paredit a go, as Emacsen generally talk about how good it is in Emacs, once you get the hang of it.

If I have an expression that passes a lambda to a function:

(wrapper-func (fn [] whatever))

And I want to change it so that all I'm left with is the inner lambda:

(fn [] whatever)

What's the right way to do that using paredit? I keep getting frustrated and going back to balancing parens by hand. I can generally get as far as deleting the 'wrapper-func' element in the list, finishing with:

((fn [] whatever))

But then it seems impossible to remove the outer or inner parens.


Solution

  • From paredit's help:

    <Leader>I      Raise the current symbol, i.e. replace the current list with
                   the current symbol by deleting everything else (except the
                   symbol) in the list, including the eclosing pair of parens.
                   For example pressing <Leader>I at position marked with |:
                       (aaa (b|bb ccc) ddd)  --->    (aaa |bbb ddd)
    

    So, place your cursor here

    (wrapper-func (fn [] whatever))
                  ^
    

    and press <Leader>I.

    See more at :help paredit.