I often need to swap s-expressions. How can I do that with paredit? I want to do things like the following:

(list |1 0)
(list 0 |1)


(list 1 |0)
(list |0 1)
  • 5
    Emacs has a command for that by default, it's bound to C-M-t. – user12563 Sep 2 '18 at 15:14
  • 1
    What @DoMiNeLa10 said. At least for the two simple examples you show, I see no need for paredit. Just put your cursor between two sexps and transpose them. (And use C-M-f or C-M-b to move forward/backward over sexps.) But different people use Emacs differently. – Drew Sep 2 '18 at 22:49
  • Thanks to both of you it works perfectly. Feel free to post an answer, so that I can select it. :) – Antoine Sep 3 '18 at 13:38

Emacs comes with such command out of the box, transpose-sexps. It's bound to C-M-t by default.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.