Home

Awesome

<p align="center"><img src="https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/master/img/logo.png"/></p>

License GPL 3 MELPA Build Status

Donate Paypal

Syntax highlighting support for "Modern C++" - until C++20 and Technical Specification. This package aims to provide a simple highlight of the C++ language without dependency.

It is recommended to use it in addition with the c++-mode major mode for extra highlighting (user defined types, functions, etc.) and indentation.

Preview

With modern-c++-font-lock-mode:

<p align="center"><img src="https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/master/img/mc%2B%2Bfl-on.png" /></p>

Using GNU Emacs 27.0.50 and CC Mode version 5.33.2.

Installation

Melpa

modern-cpp-font-lock is available on the major package.el community maintained repo - MELPA.

You can install it with the following command:

<kbd>M-x</kbd> package-install <kbd>[RET]</kbd> modern-cpp-font-lock <kbd>[RET]</kbd>

In your init Emacs file add:

(add-hook 'c++-mode-hook #'modern-c++-font-lock-mode)

or:

(modern-c++-font-lock-global-mode t)

use-package

In your init Emacs file add:

(use-package modern-cpp-font-lock
  :ensure t)

Manual

Global setup

Download modern-cpp-font-lock.el into a directory of your load-path. Place the following lines in a suitable init file:

(require 'modern-cpp-font-lock)
(modern-c++-font-lock-global-mode t)

modern-c++-font-lock-mode will be activated for buffers using the c++-mode major-mode.

Local

For the current buffer, the minor-mode can be turned on/off via the command:

<kbd>M-x</kbd> modern-c++-font-lock-mode <kbd>[RET]</kbd>

Configuration

C++ Language

You can modify the following lists to recognize more words or set it to nil to partially disable font locking:

Set to t (default value) to enable the following options or otherwise to nil:

Configure the following list to customize font locking for literal integers:

C++ standard library

Set to t (default value) to enable the following font lock options. Otherwise use nil:

Mode line

When modern-c++-font-lock-mode is activated, mc++fl is displayed.

<p align="center"><img src="https://raw.githubusercontent.com/ludwigpacifici/modern-cpp-font-lock/master/img/mode-line.png" width="640" /></p>

Wiki

The Wiki is available: https://github.com/ludwigpacifici/modern-cpp-font-lock/wiki

Testing

Font-lock keywords are tested with the faceup package of Anders Lindgren.

Feedback

If you find a bug, please check if you can reproduce with c++-mode only. If it is the case, send your bug upstream to CC Mode

Do not hesitate to ask questions or share suggestions.

Happy coding!

Lud