Reputation: 18005
Is there an Emacs package for moving Lisp (Clojure specifically) S-expressions around ?
Note : I keep seeing how to move the cursor between S-Expressions, but this is not what I am looking for. I want to move the expressions instead :
I am looking for something like that :
(a-fn 1 2 3)
'(another-thing 2 3 4)
↑cursor here
Then if I do something like "move sexp-up" of "swap-sexp", the result should be :
↓cursor here
'(another-thing 2 3 4)
(a-fn 1 2 3)
Upvotes: 1
Views: 262
Reputation: 4235
As mentioned, lispy and paredit are the packages you want to have a look at. Lispy has the advantage of short key bindings, but this comes at the cost of having to ensure the pointer is before/after a sexp and the active region is on.
Paredit has longer key bindings, but does not have the restrictions on where the pointer is and the region doesn't need to be active. I tend to use paredit - while it takes a bit of time to get use to it, once you have, it makes things very fast.
Upvotes: 1
Reputation: 17773
The built-in transpose-sexps
function should do what you want.
For much more structured s-expression editing that works well with Clojure, you should give ParEdit a try.
http://www.emacswiki.org/emacs/ParEdit
Upvotes: 6