When editing lisp code, I often end up with trailing parentheses scattered around (assuming | is point):

(defun example-function ()
  (let ((x (+ 1 1)))
    (when x
      (message x)|

Are there any convenience commands for fixing this? Either in core Emacs, paredit/smartparens, or other packages?

I know I can press ) and paredit-close-round will fix the next parenthesis, but I want to fix all of them in one command.


i (lispy-tab) from lispy does just that. Below is a screenshot of an ERT test visualization (using xv (lispy-view-test)).


  • To clarify: point needs to be at the beginning of the defun for this to work, correct? – Wilfred Hughes Apr 11 '16 at 12:13
  • Yes, the operation always applies to the current sexp. Wouldn't want to re-indent unrelated code. – abo-abo Apr 11 '16 at 12:18

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.