How to delete extra parens in Paredit mode?

11,062

Solution 1

This is called paredit-splice-sexp, keybinding is M-s. Take a look at the paredit cheat sheet here.

Solution 2

Read up on barfage and slurpage.

You can also installed "paredit-menu.el" which provides a menu of actions, with tooltips that show you their effects.

Paredit occasionally gets you into a situation when the easiest thing to do is to turn it off, fix everything and turn it on again. However, it is worth the effort.

Solution 3

If I realized accidental extra parens right after inserting those extra parens, I would invoke the undo command. If I saw the extra parens much later, then there are paredit commands for fixing it as other answers specified, but if I did not know those commands, then I would have put point somewhere within the inner form, and then typed the following, provided that CUA mode is on.

C-M-u C-M-SPC C-x <timeout> <left> C-M-SPC C-v
Share:
11,062
Sathish
Author by

Sathish

Updated on June 24, 2022

Comments

  • Sathish
    Sathish almost 2 years

    I'm using Paredit in Emacs to edit Lisp code. How do I delete an extra pair of parens that I accidentally inserted? Paredit does not allow this without extra commands.

    ((square 5)) into (square 5)