Emacs Init: Highlight Brackets

By Xah Lee. Date: . Last updated: .

Show Paren Mode

show-paren-mode → Highlight matching brackets when cursor is on a bracket.

put this in your Emacs Init File:

;; highlight matching paren
(show-paren-mode 1)
emacs show-paren-mode 2021-09-30 dnSk
emacs show-paren-mode, highlight brackets

💡 TIP: Exactly which characters are considered matching brackets depends on the buffer's Syntax Table, which usually is set by current Major Mode . For example, in emacs-lisp-mode, the curly brackets {} are not considered matching pairs, thus not highlighted.

Styles of Show Matching Paren

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)

Emacs, Work with Brackets