![]() |
Cell2Fire
A large-scale forest fire simulator.
|
TL;DR: Install the clang-format linter and use it in your IDE or editor, it should automatically use the .clang-format
file in the project root.
For C++ code, clang-format
is used to ensure consistent code formatting according to the rules specified in the .clang-format file. Formatting details can be found in the documentation.
# basic example # install sudo apt install clang-format # use clang-format -i -style=file my-code.cpp
Some IDE or editor integrations are listed below. As a last resort, use a pre-commit hook!
Clang-Format
extensionsettings.json
: Requirements: Already installed CLion and have the appropiate .clang-format
file in the project root.
CLion will automatically enable ClangFormat and apply the settings found in the file if it's under the project root.
To manually run the formatting, use ctrl + alt + shift + L.
You can also enable automatic formatting on save, go to Settings | Tools | Actions on save and enable "Reformat code".
You can find more information in the official CLion documentation.
Requirements: Already installed vim and ALE plugin
Add the following configuration to your .vimrc
Notice: This is not needed for this project, as we already have a .clang-format
file in the project root.
sudo apt install clang-format # install clang-format clang-format -style=gnu -dump-config > .clang-format # create .clang-format settings file vim .clang-format # modify .clang-format to your liking clang-format -i -style=file my-code.cpp # format a file