clang-format
インストール
$ sudo apt install clang-format # Ubuntu $ brew install clang-format # macOS
使い方
基本スタイルとファイルを指定して整形する
$ clang-format -style=google dusty.cpp > purge.cpp
結果を上書きするには-i
$ clang-format -style=google -i overwrite.cpp
スタイルを細かく指定もできる
$ clang-format -style="{BasedOnStyle: Google, IndentWidth: 4, Standard: Cpp11}" dusty.cpp
スタイルファイルを作成して指定する
.clang-format
で作成し、プロジェクトディレクトリに配置する(と、そのディレクトリ以下にあるファイルで適用される)
$ clang-format -style=file dusty.cpp
--- BasedOnStyle: Google IndentWidth: 4 Standard: Cpp11 ...