I rely on toggle-quotes (to switch between single and double quotes), but I'm not finding any available packages that can do the same for switching between pairs of ( [ { <. I'd expect it to cycle between the four (and maybe /). Does it exist (yet)?

1 Answer 1


This is a simplistic way to accomplish it for lisp modes (for the limited cases I just tried), using some smartparens functions:

(defun toggle-parens ()
  "Toggle parens, braces, brackets."
    (when (not (string-match-p (regexp-quote (char-to-string (char-after))) "([{<"))
      (when (eq ?\" (char-after)) ; up again if inside string
       (case (char-after)
         (?\( "[")
         (?\[ "{")
         (?\{ "(")
         ;; smartparens can't wrap with <
         ;; (?\< "(")
(global-set-key (kbd "C-c S") 'toggle-parens)

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.