Emacs: Color Nested Brackets
rainbow-delimiters-mode
colors nested brackets with different color.
rainbow-delimiters-mode
by Jeremy L Rayman at
https://github.com/Fanael/rainbow-delimiters.
It's in MELPA 〔see Emacs: Install Package with ELPA/MELPA〕.
Alt+x rainbow-delimiters-mode
to turn on for current buffer.
To turn on for all programing modes, put the following in your emac init:
(require 'rainbow-delimiters) (add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
It colors brackets by their nesting level. By default, most brackets are colored gray. You can customize it like this:
Setting up colors, with every third parenthesis red.
(custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(rainbow-delimiters-depth-1-face ((t (:foreground "red")))) '(rainbow-delimiters-depth-2-face ((t (:foreground "black")))) '(rainbow-delimiters-depth-3-face ((t (:foreground "black")))) '(rainbow-delimiters-depth-4-face ((t (:foreground "red")))) '(rainbow-delimiters-depth-5-face ((t (:foreground "black")))) '(rainbow-delimiters-depth-6-face ((t (:foreground "black")))) '(rainbow-delimiters-depth-7-face ((t (:foreground "red")))) '(rainbow-delimiters-depth-8-face ((t (:foreground "black")))) '(rainbow-delimiters-depth-9-face ((t (:foreground "black")))) '(rainbow-delimiters-unmatched-face ((t (:background "cyan")))) )
Decreasing Bracket Size
rainbow-delimiters-mode setup, with decreasing bracket size:
;; rainbow-delimiters-mode setup, with decreasing bracket size (custom-set-faces ;; custom-set-faces was added by Custom. ;; If you edit it by hand, you could mess it up, so be careful. ;; Your init file should contain only one such instance. ;; If there is more than one, they won't work right. '(rainbow-delimiters-depth-1-face ((t (:foreground "red" :height 2.0)))) '(rainbow-delimiters-depth-2-face ((t (:foreground "orange" :height 1.8)))) '(rainbow-delimiters-depth-3-face ((t (:foreground "yellow" :height 1.6)))) '(rainbow-delimiters-depth-4-face ((t (:foreground "green" :height 1.4)))) '(rainbow-delimiters-depth-5-face ((t (:foreground "blue" :height 1.2)))) '(rainbow-delimiters-depth-6-face ((t (:foreground "violet" :height 1.1)))) '(rainbow-delimiters-depth-7-face ((t (:foreground "purple" :height 1.0)))) '(rainbow-delimiters-depth-8-face ((t (:foreground "black" :height 0.9)))) '(rainbow-delimiters-unmatched-face ((t (:background "cyan" :height 0.8)))) )