clang-format is LLVM’s code formatter for C/C++. As with clangd and clang-tidy, we can specify clang-format settings in a .clang-format file in the project root.

To disable and enable around a section:

// clang-format off
// clang-format on

Miscellaneous tips:

  • git clang-format -f to format only modified files in place