1. why use clang-format?
- important to raise the code quality
- formatting your code is important is that you get a uniformed code when reading it, meaning you will decrease the “WTF per minute”-score*.
install
clang-format
1
sudo apt-get install clang-format
config .clang-format
1
2cd <path to repo>
clang-format -style=llvm -dump-config > .clang-formatalso you can choose another style or custom your style by changing .clang-format.
how to use
after editing the code. do it as follows:
1 | git add -u |
The clang-format will format the staged code, you can use git diff to check whether the clang-format is work.