Clang Format
2016-05-24 16:41
309 查看
1,最近项目代码要求规范化,在网上找了个Xcode插件:Clang Format ,下载地址:https://github.com/travisjeffery/ClangFormat-Xcode
2,设置快捷键:系统偏好设置 -》键盘-》快捷键-》应用快捷键-》+
3, 选择的格式不是我们想要的,和iOS的编码规范还是有一定差别的,自定义我们自己的格式吧
创建 _clang-format 文件,内容如下:
将这个文件加到 .xcodeproj 包内容里,就OK了,或者是放到主目录也是OK的
附:常用的设置命令
如此设置过一次就可以了,别的项目就不需要如此设置
2,设置快捷键:系统偏好设置 -》键盘-》快捷键-》应用快捷键-》+
应用程序里选择:Xcode,菜单标题:Format Selected Files , 键盘快捷键选择:ctr + \ 应用程序里选择:Xcode,菜单标题:Format File in Focus, 键盘快捷键选择:car + cmd + \
3, 选择的格式不是我们想要的,和iOS的编码规范还是有一定差别的,自定义我们自己的格式吧
创建 _clang-format 文件,内容如下:
# 基础样式 BasedOnStyle: LLVM # 缩进宽度 IndentWidth: 4 # 圆括号的换行方式 BreakBeforeBraces: Attach # 支持一行的if AllowShortIfStatementsOnASingleLine: true # switch的case缩进 IndentCaseLabels: true # 针对OC的block的缩进宽度 ObjCBlockIndentWidth: 4 # 针对OC,属性名后加空格 ObjCSpaceAfterProperty: true # 每行字符的长度 ColumnLimit: 0 # 注释对齐 AlignTrailingComments: true # 括号后加空格 SpaceAfterCStyleCast: true # 不在小括号里加空格 SpacesInParentheses: false # 不在中括号里加空格 SpacesInSquareBrackets: false
将这个文件加到 .xcodeproj 包内容里,就OK了,或者是放到主目录也是OK的
附:常用的设置命令
AccessModifierOffset: 0 AlignEscapedNewlinesLeft: false AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: false AllowShortFunctionsOnASingleLine: false AllowShortIfStatementsOnASingleLine: false AllowShortLoopsOnASingleLine: false AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: false BinPackParameters: false BreakBeforeBinaryOperators: false BreakBeforeTernaryOperators: false BreakConstructorInitializersBeforeComma: false ColumnLimit: 128 BreakBeforeBraces: Attach CommentPragmas: '' ConstructorInitializerAllOnOneLineOrOnePerLine: false ConstructorInitializerIndentWidth: 0 ContinuationIndentWidth: 0 Cpp11BracedListStyle: false DerivePointerBinding: false IndentCaseLabels: true IndentFunctionDeclarationAfterType: false IndentWidth: 4 Language: Cpp MaxEmptyLinesToKeep: 1 NamespaceIndentation: None ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true ObjCBlockIndentWidth: 4 PenaltyBreakBeforeFirstCallParameter: 100 PenaltyBreakComment: 100 PenaltyBreakFirstLessLess: 0 PenaltyBreakString: 100 PenaltyExcessCharacter: 1 PenaltyReturnTypeOnItsOwnLine: 20 SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false SpacesBeforeTrailingComments: 1 SpacesInAngles: false SpacesInCStyleCastParentheses: false SpacesInContainerLiterals: false SpacesInParentheses: false TabWidth: 4 UseTab: Never
如此设置过一次就可以了,别的项目就不需要如此设置
相关文章推荐
- C++ 值传递、指针传递、引用传递
- mysql 修改data目录后 无法使用脚本启动 推荐
- 第13周-交通类(3)
- 模拟实现部分库函数(strcpy,strcmp,strcat,strstr,memcpy,memmove,memset)
- Picasso 图片请求库(工具类)
- Open Baidu webpage and type in Chinese characters to start searching, press “Back” button to go to B
- 3、Git基本的工作流程
- HDU 1669 Monkey and Banana
- JavaScript学习
- RRC连接重配置
- java中GC回收和内存分配
- 《统计学习方法》——概论
- Unity3D中的Update, FixedUpdate, LateUpdate的区别
- file_put_contents 错误:failed to open stream: Invalid argument 一种原因
- BBC英语-drama
- IP地址中的保留地址
- Ubuntu下U盘文件只读的解决办法
- R语言学习之路(二)矩阵
- Contains Duplicate
- Lua读取文件和写入文件