Skip to content


Folders and files

Last commit message
Last commit date

Latest commit



25 Commits

Repository files navigation


A clang-format utility.

It will automatically format your C++ closer to the slightly-quirky format laid out here.

Note that the tool does not have perfect coverage; some amount of work is still necessary to make your code fully adhere to the style guide.


clang-format rewrites your source-code. Make sure to have your code in a source-control system, so it can't do any permanent damage.


 $ cd <my-project>
 $ curl "" > .clang-format
 $ clang-format -i *.h *.cc

Note that clang-format is idempotent, so you can run it as many times as you want.


In order to use this tool, you need two things.

  • clang-format
  • A style-file (this is provided by this repo; see the curl command above)

There are three ways to get clang-format; you can use a package manager, build from source, or just use the provided binaries. Note that building from source can take a considerable amount of time.

Using Package Managers

With OS X and recent versions of homebrew, you can run:

brew install clang-format

Building clang-format From Source

$ cd ~
$ svn co llvm
$ cd llvm/tools
$ svn co clang
$ cd ~/llvm
$ ./configure
$ make

After executing the instructions above, clang-format will be in ~/llvm/Debug+Asserts/bin/clang-format.

Using the Provided Binaries


For Linux (thanks, Kalsi!)