What is Clang-Format and how does JetBrains Rider support it?
Clang-Format is a widely-used C++ code formatter. As it provides an option to define code style options in YAML-formatted files — named .clang-format or _clang-format— these files often become a part of your project where you keep all code style rules. To see the full list of Clang-Format style options and examples of configuration files, check out the Clang-Format documentation.
Clang-Format in your solution
By default, Clang-Format properties are enabled; they will override preferences defined in JetBrains Rider settings as well as EditorConfig styles. If you want JetBrains Rider to ignore Clang-Format styles for code formatting and code syntax, clear the corresponding checkbox on the page of JetBrains Rider settings.
When Clang-Format support is enabled and there are .clang-format or _clang-format files that affect the current file, JetBrains Rider will help you understand which Clang-Format styles are applied and where these settings come from:
Export code style settings to Clang-Format
If you are going to share code style settings via Clang-Format, you may want to export the styles already configured in JetBrains Rider to the .clang-format file.
Press Ctrl+Alt+S or choose(Windows and Linux) or (macOS) from the menu, then choose on the left.
In the Clang-Format" section, click Export. This will open the Export to .clang-format dialog.
By default, JetBrains Rider writes the settings to a new .clang-format file in the root directory of the current solution. If one or more .clang-format files exist, JetBrains Rider will use the closest file in the directory hierarchy to save the settings. If necessary, you can change the destination file using the path selector at the top of the dialog.
If there is an existing .clang-format file in the specified location, there could be conflicts between values of properties that exist there and the ones that JetBrains Rider is about to save. Such properties will be shown in red and if you proceed with saving, the conflicts will be resolved in favor of the newly generated ones.
Click Export. JetBrains Rider will create or update the .clang-format file in the specified location.
You can also save formatting styles to Clang-Format after contextual configuration of formatting rules.
Supported Clang-Format Options