Clang Format
1,最近项目代码要求规范化,在网上找了个Xcode插件:Clang Format ,下载地址:https://github.com/travisjeffery/ClangFormat-Xcode
2,设置快捷键:系统偏好设置 -》键盘-》快捷键-》应用快捷键-》+
应用程序里选择:Xcode,菜单标题:Format Selected Files , 键盘快捷键选择:ctr + \
应用程序里选择:Xcode,菜单标题:Format File in Focus, 键盘快捷键选择:car + cmd + \
3, 选择的格式不是我们想要的,和iOS的编码规范还是有一定差别的,自定义我们自己的格式吧
- 创建 _clang-format 文件,内容如下:
# 基础样式 BasedOnStyle: LLVM # 缩进宽度 IndentWidth: # 圆括号的换行方式 BreakBeforeBraces: Attach # 支持一行的if AllowShortIfStatementsOnASingleLine: true # switch的case缩进 IndentCaseLabels: true # 针对OC的block的缩进宽度 ObjCBlockIndentWidth: # 针对OC,属性名后加空格 ObjCSpaceAfterProperty: true # 每行字符的长度 ColumnLimit: # 注释对齐 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
如此设置过一次就可以了,别的项目就不需要如此设置
Clang Format的更多相关文章
- clang format 官方文档自定义参数介绍(中英文)
官方文档:http://clang.llvm.org/docs/ClangFormatStyleOptions.html 中文 在代码中配置样式 当使用 clang::format::reformat ...
- 在Xcode中使用Clang Format
Xcode中的Re-Indent,顾名思义,只是一个调整缩进的功能,完全依赖它来进行代码格式化显然不够用.我们使用了一个叫做ClangFormat-Xcode的插件,配合Re-Indent一起来做代码 ...
- clang format 自定义样式常用参数说明
常用的格式设置: #如果为真(true),分析格式化过的文件中最常见的&和*的对齐方式.然后指针对齐仅作为回退 DerivePointerAlignment: false #缩进宽度 Inde ...
- a great tool for automatically formating your code!
1. make your own format file at your project's root or file's folder. (The clang-format will automat ...
- 征服恐惧!用 Vim 写 iOS App
我们都知道 Vim 和 Emacs 都是文本编辑器中的上古神器,你也许用 ctags,cscopes 配合 Vim 完成过大型 C 或者 C++ 的开发,你也许配合过其他插件,完成过 JavaScri ...
- ROS知识(21)----ROS C++代码格式化
这里提供两种方法. 第一种方法:clang_format 1.安装clang format sudo apt-get install -y clang-format-3.6 2.从github的ros ...
- Android Studio xcode单步调试 WebRTC Android & iOS
mac环境 如何在 Android Studio 里单步调试 WebRTC Android 的 native 代码. WebRTC 代码下载 depot tools 是 chromium 代码库管理工 ...
- Qt Creater中Clang-format的使用
起因在于习惯性的想格式化代码,发现Qt Creater默认居然是没有代码格式化的,只有一个缩进,搞毛线啊!!! 搜索了下,倒是很容易就搜到了,Qt Creater中有个插件:beautifier,在 ...
- Vim 写 iOS App
Vim 写 iOS App 我们都知道 Vim 和 Emacs 都是文本编辑器中的上古神器,你也许用 ctags,cscopes 配合 Vim 完成过大型 C 或者 C++ 的开发,你也许配合过其他插 ...
随机推荐
- Python爬虫学习(10):Selenium的好基友PhantomJS
上一节中我们学习了selenium,用python来操作浏览器,在做网页自动化测试的时候最好不过了 .如果我们来做爬虫用一个带界面的浏览器似乎不太好吧,那可咋办呢?别着急,下来我们要介绍的就是一款不带 ...
- 动作手游实时PVP技术揭密(服务器篇)
前言 我们的游戏是一款以忍者格斗为题材的ACT游戏,其主打的玩法是PVE推图及PVP 竞技.在剧情模式中,高度还原剧情再次使不少玩家泪目.而竞技场的乐趣,伴随着赛季和各种赛事相继而来,也深受玩家喜爱, ...
- 树形DP+DFS序+树状数组 HDOJ 5293 Tree chain problem(树链问题)
题目链接 题意: 有n个点的一棵树.其中树上有m条已知的链,每条链有一个权值.从中选出任意个不相交的链使得链的权值和最大. 思路: 树形DP.设dp[i]表示i的子树下的最优权值和,sum[i]表示不 ...
- iOS Swift 数组 交换元素的两种方法
swap(&arr[fromIndexPath.row], &arr[to.row]) (arr[fromIndexPath.row],arr[to.row]) = (arr[to.r ...
- 弱省互测#2 t3
题意 给出\(n\)个01字节和\(m\)个01字节,要求用后者去匹配前者,两个串能匹配当且仅当除了每个字节末位不同,其他位都要相同.问匹配后者至少有多少个末位不同.(\(1 \le m \le n ...
- 第三章 一个简单的机器学习例子让你了解DeepLab的语言风格
MINST是由Yann LeCun等人建立并维护的手写数字识别数据库.该数据库总共包含60000个训练样本和10000个测试样本.其中每个样本的大小是一张28*28的手写数字图片.数字包括从0~9总共 ...
- BestCoder Round 69 Div 2 1001&& 1002 || HDU 5610 && 5611
题目:http://acm.hdu.edu.cn/showproblem.php?pid=5610 如果杠铃总质量是奇数直接impossible 接着就考验耐心和仔细周全的考虑了.在WA了三次后终于发 ...
- xcode 一般插件
插件编写 xcode的插件不算多,找遍了网络也就大猫小猫而三只.不过虽然不多,但是大部分的插件都非常有用.以下5歀插件是我几台机器上都安装了并且经常使用的. 1. MiniXcode MiniXcod ...
- mysql问题总结
1. You are using safe update mode and you tried to update a table without a WHERE clause that uses a ...
- FastDateFormat
1 public static final FastDateFormat ISO_DATE_FORMAT = FastDateFormat.getInstance("yyyy-MM-dd&q ...