clang-format

Tool to auto-format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. More information: <https://clang.llvm.org/docs/ClangFormat.html>.

Install

All systems
curl cmd.cat/clang-format.sh
Debian Debian
apt-get install clang-format
Ubuntu
apt-get install clang-format
Alpine
apk add clang
Arch Arch Linux
pacman -S clang
image/svg+xml Kali Linux
apt-get install clang-format
CentOS
yum install clang
Fedora
dnf install clang
Windows (WSL2)
sudo apt-get update sudo apt-get install clang-format
OS X
brew install clang-format
Raspbian
apt-get install clang-format
Docker
docker run cmd.cat/clang-format clang-format powered by Commando

Tool to auto-format C/C++/Java/JavaScript/Objective-C/Protobuf/C# code. More information: <https://clang.llvm.org/docs/ClangFormat.html>.

  • Format a file and print the result to `stdout`:
    clang-format path/to/file
  • Format a file in-place:
    clang-format -i path/to/file
  • Format a file using a predefined coding style:
    clang-format --style=LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit path/to/file
  • Format a file using the `.clang-format` file in one of the parent directories of the source file:
    clang-format --style=file path/to/file
  • Generate a custom `.clang-format` file:
    clang-format --style=LLVM|GNU|Google|Chromium|Microsoft|Mozilla|WebKit --dump-config > .clang-format

© tl;dr; authors and contributors