Cod*_*ton 5 xcode lint objective-c clang-format
我正在为我的Objective-C项目使用clang-format,但是我在设置它时遇到了困难.
这是我想要的结果:
- (NSString *)someMethod
{
return @"My String";
}
Run Code Online (Sandbox Code Playgroud)
这是格式化后的实际结果:
- (NSString *)someMethod {
return @"My String";
}
Run Code Online (Sandbox Code Playgroud)
这是我的.clang-format档案:
BasedOnStyle: WebKit
AlignTrailingComments: true
ColumnLimit: 120
IndentWidth: 2
KeepEmptyLinesAtTheStartOfBlocks: false
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PointerBindsToType: false
SpacesBeforeTrailingComments: 1
TabWidth: 2
UseTab: Never
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: true
AfterControlStatement: false
AfterEnum: true
AfterExternBlock: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: true
AfterStruct: true
AfterUnion: true
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
SplitEmptyNamespace: true
Run Code Online (Sandbox Code Playgroud)
我需要更改什么设置才能让格式化程序在Objective-C方法的开头括号之前放置换行符?
对于您的任何微调,clang-format您最好不要使用BasedOnStyle,因为对我来说,这只会创建随机且难以调试的结果。
最简单的方法可能是设置:BreakBeforeBraces: Custom然后按照您想要的方式设置所有内容,如文档中所述:
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: true
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
261 次 |
| 最近记录: |