I'm using Spacemacs, and I REALLY love how Dr. Racket background highlights parentheses as you move around.

I'm wondering if I can do this in Emacs instead of this God forsaken "rainbow delimiters" that give me a headache.

enter image description here

2 Answers 2


With show-paren-mode you can highlight the whole expression. You need to have the following code in your init file. You can try different style and choose what you like to highlight.

(show-paren-mode t) ;; enable show paren mode

(setq show-paren-style 'expression) ;; highlight whole expression

Refer : http://emacs-fu.blogspot.in/2009/01/balancing-your-parentheses.html

  • If spacemacs isn't autocompleting the symbol 'expression does that mean its unavailable? It doesn't seem to be working. I noticed it autocompletes show-paren-style but not the value.
    – Tallboy
    Commented Jan 2, 2018 at 3:33
  • I got it working, I had to add both lines. Do you know how I can make it change the background color rather than changing the text color? Thanks!
    – Tallboy
    Commented Jan 2, 2018 at 5:43
  • Tallboy: The link that Hariharan provided gave you that information.
    – phils
    Commented Jan 2, 2018 at 8:46
  • Ok thanks, sorry I must have missed that.
    – Tallboy
    Commented Jan 2, 2018 at 17:21
  • @Tallboy Emacs completion does not consider all interned symbols, only bound ones. Clearly expression is an arbitrary, unbound symbol in this case. If show-paren-style hadn't previously been defined as a variable, you wouldn't be able to complete it either.
    – Basil
    Commented Jan 14, 2018 at 12:04

I actually want to change the selected answer to myself after doing a lot more research. The given answer above is close, but not quite. It highlights the entire line which I don't want (for example it won't highlight the (circle 10) inside (visalign (circle 10) (circle 20)).

For this, I ended up using this package:

dotspacemacs-additional-packages '(
  (highlight-sexp :location (recipe :fetcher github :repo "daimrod/highlight-sexp"))

And my config in user-config:

(setq hl-sexp-foreground-color nil)
(setq hl-sexp-background-color "#333")

If that doesn't work for you, I found various sexp highlight packages. They're all slightly different. For example one includes the parens, another doesn't. But for the most part they all do the same thing.

  • 1
    FWIW, show-paren-mode with show-paren-style set to 'expression works fine for me, e.g. (circle 10) is also highlighted.
    – Basil
    Commented Jan 14, 2018 at 12:08
  • show-paren-style works for me when the cursor is over one of the parens enclosing an expression, this updated answer involving highlight-sexp highlights the whole expression when the cursor is anywhere in the expression.
    – drhodes
    Commented May 15, 2019 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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