Skip to content
Ludwig PACIFICI edited this page Jun 27, 2017 · 2 revisions

Wiki modern-cpp-font-lock

Customization

Example: Enable font-lock for more operators

By default, operators are no font locked (to avoid the christmas tree effect). However, you could argue they can be overloaded and it could make sense to highlight all/some of them. It is a perfect example to show you how to customize this minor-mode:

With c++-mode and modern-c++-font-lock-mode enabled, you will see by default:

Add (add-to-list 'modern-c++-operators "=") in your init file to enable extra font locking for operators. Now, = is highlighted:

Example: Disable font-lock for attributes

You do not like some part of the font-locking? Fair enough. Let's disable the syntax highlighting for C++ attributes.

With c++-mode and modern-c++-font-lock-mode enabled, you will see by default:

Add (setq modern-c++-attributes nil) in your init file to disable font locking for C++ attributes. Now, [[maybe_unused]] is no more highlighted:

Known issues

Correct string literals display

With modern-c++-literal-string set to t, string literals will be displayed correctly with cc-mode >= 5.33.