Skip to content

Instantly share code, notes, and snippets.

@hackorama
Created June 11, 2018 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hackorama/17953ba20d891e0e3cb8d85c99236b87 to your computer and use it in GitHub Desktop.
Save hackorama/17953ba20d891e0e3cb8d85c99236b87 to your computer and use it in GitHub Desktop.
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