Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Using clang-format

Use clang-format on full code base

$ sudo apt-get install git-clang-format
$ clang-format --version
clang-format version 3.8.0-2ubuntu4 (tags/RELEASE_380/final)
$
$ clang-format -i *.cpp *.h
$

To use clang-format with git changes only, use git-clang-format

Check if already installed

$ which git-clang-format
$
$ which git-clang-format-3.8
/usr/bin/git-clang-format-3.8
$ ls -l /usr/bin/git-clang-format-3.8
lrwxrwxrwx 1 root root 36 Jul 12  2016 /usr/bin/git-clang-format-3.8 -> ../lib/llvm-3.8/bin/git-clang-format
$

If not installed install git-clang-format

$wget https://raw.githubusercontent.com/llvm-mirror/clang/master/tools/clang-format/git-clang-format
$ git add .
$ git-clang-format-3.8
changed files:
    anyoption.cpp
$  git add anyoption.cpp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.