Clang-Format的使用及其自定义格式

如何安装请参考

http://blog.csdn.net/zcube/article/details/50546845

配置示例

#访问修饰符偏移量
#AccessModifierOffset: 0
#  @public
#  NSMutableArray *_cellHeightArray;
#AccessModifierOffset: 4
#    @public
# NSMutableArray *_cellHeightArray;

AccessModifierOffset: 0

#如果是true就是左对齐,如果是false就是右对齐
# true
# if (foo && // Some comment
# bar) {
#    baz();
# }
#
#void foo() {
#    someFunction();
#    someOtherFunction();
#}
#-----------------------------
#false
#if (foo && // Some Comment
#    bar) {
#            baz();
#}
#
#void foo() {
#            someFunction();
#       someOtherFunction();
#}
AlignEscapedNewlinesLeft: true

#注释的对齐方式 如果是true将左对齐,如果是false不会对齐
AlignTrailingComments: false

#函数多个参数的对齐方式,如果TRUE就让参数上下对齐 否则将是默认
AllowAllParametersOfDeclarationOnNextLine: false

#是否允许方法单行
AllowShortFunctionsOnASingleLine: false

#是否允许if单行
AllowShortIfStatementsOnASingleLine: false

#是否允许循环单行
AllowShortLoopsOnASingleLine: false

#在多行字符串之前总是打破(对齐)
AlwaysBreakBeforeMultilineStrings: false

#总是打破模板声明
AlwaysBreakTemplateDeclarations: false

#如果为 false,函数调用或函数定义的参数将会都是在同一行上或者会有一行每个。
BinPackParameters: false

#如果为 true,则将换行符后放置二元运算符。
BreakBeforeBinaryOperators: false

#大括号使用的样式
BreakBeforeBraces: Allman

#如果为 true,则将换行符后放置三元运算符。
BreakBeforeTernaryOperators: false

#总是打破在逗号之前的构造函数初始值设定项和对齐以冒号逗号。
BreakConstructorInitializersBeforeComma: false

#每一行限制字符的长度
ColumnLimit: 120
CommentPragmas: ''

#如果在构造函数初始值设定项不适合在一条线,把每个初始值设定项放在自己的行上。
ConstructorInitializerAllOnOneLineOrOnePerLine: false

ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 0
Cpp11BracedListStyle: false
DerivePointerBinding: false

#switch case的缩进
IndentCaseLabels: true

IndentFunctionDeclarationAfterType: false
IndentWidth: 4
Language: Cpp
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 100
PenaltyBreakComment: 100
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 100
PenaltyExcessCharacter: 1
PenaltyReturnTypeOnItsOwnLine: 20
PointerBindsToType: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: Always
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
Standard: Cpp11
TabWidth: 4
UseTab: Never
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 176,093评论 25 709
  • 在此特此声明:一下所有链接均来自互联网,在此记录下我的查阅学习历程,感谢各位原创作者的无私奉献 ! 技术一点一点积...
    远航的移动开发历程阅读 13,892评论 12 197
  • 网站: http://ui4app.com/category 技术网站: http://www.bestsdk.c...
    LYPC_下里巴人阅读 4,897评论 0 1
  • 今天休息,坐在沙发上看书,看到书中的女人经历了失婚,车祸致残,都执着于自己的梦想,最终活出了花的绚丽,舞出自己独特...
    合众爱文清阅读 2,607评论 0 0
  • 我心爱山水但我心无山水。拿笔画过很多东西,偏偏山水不敢画,原因很简单---我心无山水! 一个朋友劝过我:“你别画山...
    刘佳画室阅读 3,290评论 12 9

友情链接更多精彩内容