Created
January 12, 2016 08:31
-
-
Save vincenthsu/28c51535719d6bbe2238 to your computer and use it in GitHub Desktop.
clang-format example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
Language: Cpp | |
# BasedOnStyle: WebKit | |
AccessModifierOffset: -4 | |
AlignAfterOpenBracket: false | |
AlignEscapedNewlinesLeft: false | |
AlignOperands: false | |
AlignTrailingComments: true | |
AllowAllParametersOfDeclarationOnNextLine: false | |
AllowShortBlocksOnASingleLine: false | |
AllowShortCaseLabelsOnASingleLine: false | |
AllowShortIfStatementsOnASingleLine: false | |
AllowShortLoopsOnASingleLine: false | |
AllowShortFunctionsOnASingleLine: Empty | |
AlwaysBreakAfterDefinitionReturnType: false | |
AlwaysBreakTemplateDeclarations: false | |
AlwaysBreakBeforeMultilineStrings: false | |
BreakBeforeBinaryOperators: None | |
BreakBeforeTernaryOperators: false | |
BreakConstructorInitializersBeforeComma: true | |
BinPackParameters: true | |
BinPackArguments: true | |
ColumnLimit: 80 | |
ConstructorInitializerAllOnOneLineOrOnePerLine: false | |
ConstructorInitializerIndentWidth: 4 | |
DerivePointerAlignment: false | |
ExperimentalAutoDetectBinPacking: false | |
IndentCaseLabels: false | |
IndentWrappedFunctionNames: false | |
IndentFunctionDeclarationAfterType: false | |
MaxEmptyLinesToKeep: 2 | |
KeepEmptyLinesAtTheStartOfBlocks: true | |
NamespaceIndentation: Inner | |
ObjCBlockIndentWidth: 4 | |
ObjCSpaceAfterProperty: true | |
ObjCSpaceBeforeProtocolList: true | |
PenaltyBreakBeforeFirstCallParameter: 79 | |
PenaltyBreakComment: 300 | |
PenaltyBreakString: 1000 | |
PenaltyBreakFirstLessLess: 120 | |
PenaltyExcessCharacter: 1000000 | |
PenaltyReturnTypeOnItsOwnLine: 60 | |
PointerAlignment: Left | |
SpacesBeforeTrailingComments: 1 | |
Cpp11BracedListStyle: false | |
Standard: Auto | |
IndentWidth: 4 | |
TabWidth: 8 | |
UseTab: Never | |
BreakBeforeBraces: Linux | |
SpacesInParentheses: false | |
SpacesInSquareBrackets: false | |
SpacesInAngles: false | |
SpaceInEmptyParentheses: false | |
SpacesInCStyleCastParentheses: false | |
SpaceAfterCStyleCast: true | |
SpacesInContainerLiterals: true | |
SpaceBeforeAssignmentOperators: true | |
ContinuationIndentWidth: 4 | |
CommentPragmas: '^ IWYU pragma:' | |
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] | |
SpaceBeforeParens: ControlStatements | |
DisableFormat: false | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z $1 ]; then | |
EXEC_PATH=$PWD | |
else | |
EXEC_PATH=$1 | |
fi | |
# remove trailing whitespace | |
find $EXEC_PATH -type f \( -iname "*.hpp" -or -iname "*.h" -or -iname "*.c" -or -iname "*.cpp" \) -not -path "*/import/*" | xargs sed -e 's/[[:blank:]]\+$//' -i | |
# convert line endings to unix | |
find $EXEC_PATH -type f \( -iname "*.hpp" -or -iname "*.h" -or -iname "*.c" -or -iname "*.cpp" \) -not -path "*/import/*" | xargs dos2unix | |
# convert tabs to 4 spaces | |
find $EXEC_PATH -type f \( -iname "*.hpp" -or -iname "*.h" -or -iname "*.c" -or -iname "*.cpp" \) -not -path "*/import/*" | xargs sed -i 's/\t/ /g' | |
# format source code | |
find $EXEC_PATH -type f \( -iname "*.hpp" -or -iname "*.h" -or -iname "*.c" -or -iname "*.cpp" \) -not -path "*/import/*" | xargs clang-format-3.6 -i |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment