prettify symbol

prettify-symbol-alist c mode common hook

To prettify symbols in c-mode using prettify-symbols-alist, you can add a hook in your Emacs configuration file (e.g., init.el or .emacs). Here's an example:

1
2
3
4
5
6
7
8
9
(add-hook 'c-mode-hook
(lambda ()
(setq prettify-symbols-alist
'(("->" . ?→)
("==" . ?≡)
("!=" . ?≠)
("<=" . ?≤)
(">=" . ?≥)))
(prettify-symbols-mode 1)))

This hook will enable prettify-symbols-mode in c-mode and replace common C operators with prettier symbols. Adjust the prettify-symbols-alist as needed for your preferences.

add some more symbols

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(add-hook 'c-mode-common-hook
(lambda ()
(setq prettify-symbols-alist
'(("->" . ?→)
("==" . ?≡)
("!=" . ?≠)
("<=" . ?≤)
(">=" . ?≥)
("&&" . ?∧)
("||" . ?∨)
("int" . ?ℤ)
("float" . ?ℝ)
("char" . ?ℂ)
("return" . ?⏎)
("NULL" . ?∅)
("nullptr" . ?∅)
("std::vector" . ?𝑉)
("std::string" . ?𝑆)
("std::array" . ?𝐴)
("std::unique_ptr" . ?𝑃)
("true . ?𝑡)
("false . ?𝑓)
("std::unordered_map" . ?#)
("void" . ?∅)))
(prettify-symbols-mode 1)))