Emacs: Highlight Brackets ()[]{}

By Xah Lee. Date: . Last updated: .

Alt+x show-paren-mode → highlight matching brackets when your cursor is on one of the bracket.

;; turn on highlight matching brackets when cursor is on one
(show-paren-mode 1)

show-paren-mode has 2 styles of highlighting brackets.

emacs show paren mode parenthesis 33045
Alt+x show-paren-mode, highlight brackets
emacs show paren mode expression 46552
Alt+x show-paren-mode, highlight whole expression

By default, emacs highlights just the brackets.

To change a style, put this in your emacs init file:

;; highlight brackets
(setq show-paren-style 'parenthesis)

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

;; highlight brackets if visible, else entire expression
(setq show-paren-style 'mixed)

Note: show-paren-mode will highlight any brackets, including [] {} 『』 【】 〈〉 «» etc.

[see Unicode: Brackets, Quotes «»「」【】《》]

Working with Brackets

  1. Highlight Brackets ()[]{}
  2. Insert Brackets by Pair
  3. Delete Brackets ()[]{} by Pair
  4. Select Line, between Quotes, Extend Selection
  5. Move Cursor to Bracket/Quote
  6. Change Brackets/Quotes

Emacs Lisp Basics

  1. Emacs Lisp Basics
  2. Overview of Text-Processing in Emacs Lisp
  3. Emacs Lisp Examples
  4. Evaluate Emacs Lisp Code
  5. Doc Lookup
  6. Search Doc
  7. How to Edit Lisp Code
Patreon me $5 patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboards for Emacs

If you have a question, put $5 at patreon and message me.