如何用clang-format格式化objective-c块? [英] How to format objective-c block with clang-format?
本文介绍了如何用clang-format格式化objective-c块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码,例如:
[cardRegistrationVC setCancelBlock:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
当我对其应用 clang-format 时,它变成:
When I apply clang-format on it, it turns into:
[cardRegistrationVC setCancelBlock:^{ [weakSelf.navigationController popViewControllerAnimated:YES]; }];
如您所见,块内的代码出现在同一行.但我应该总是在一个新的行.
As you can see, code inside the block appears on the same line. But I should be always on a new line.
如何正确设置clang-format?我的以下设置文件:
How to set up clang-format correct? My following settings file:
BasedOnStyle: LLVM
AllowShortIfStatementsOnASingleLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakBeforeMultilineStrings: false
IndentCaseLabels: true
ColumnLimit: 120
ObjCSpaceAfterProperty: true
KeepEmptyLinesAtTheStartOfBlocks: true
PenaltyBreakString: 1000000
SpacesInContainerLiterals: false
推荐答案
最后我写了这样的块:
[cardRegistrationVC setCancelBlock:^{
[weakSelf.navigationController popViewControllerAnimated:YES];
}];
最后的空行可以正常工作.或者您必须禁用列限制:
Empty line at the end works ok. Or you have to disable column limit:
#ColumnLimit: 120
这篇关于如何用clang-format格式化objective-c块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文