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. electric-pair-mode
  3. Insert Brackets by Pair
  4. Delete Brackets ()[]{} by Pair
  5. Select Line, between Quotes, Extend Selection
  6. Move Cursor to Bracket/Quote
  7. Change Brackets/Quotes

Emacs Lisp Basics

  1. Elisp Basics
  2. ELisp Text-Processing Overview
  3. Elisp Examples
  4. Evaluate Elisp Code
  5. Doc Lookup
  6. Search Doc
  7. How to Edit Lisp Code

If you have a question, put $5 at patreon and message me.
Or Buy Xah Emacs Tutorial
Or buy a nice keyboard: Best Keyboards for Emacs

Emacs

Emacs Lisp

Misc