Using clang-format for LSST DevelopmentΒΆ

The easiest way to comply with the LSST code layout rules is to use clang-format.

You can install this tool through the Ubuntu package manager:

sudo apt-get install clang-format

or through Homebrew (on macOS):

brew install clang-format

For more platforms see here.

Place the following configuration file, named .clang-format, in your top-level source directory:

---
Language: Cpp
BasedOnStyle: Google
ColumnLimit: 110
IndentWidth: 4
AccessModifierOffset: -4
SortIncludes: false # reordering may break existing code
ConstructorInitializerIndentWidth: 8
ContinuationIndentWidth: 8
...
# newline here

Then run it with: clang-format -i -style=file mycode.cc.

See the clang-format configuration documentation for the meaning of these options.

Integration with Emacs and Vim is also available.