在Xcode中缩进连续行
我可以用Xcode的自动缩进来缩进连续行吗 我想:在Xcode中缩进连续行,xcode,indentation,Xcode,Indentation,我可以用Xcode的自动缩进来缩进连续行吗 我想: BOOL someLongVariableName = someLongValue | someOtherLongValue | moreLongValues BOOL someOtherLongVariableName = someEvenLongerValue; [someLongVariableName performSomeAction:someLongArgument] 我目前得到: BOOL s
BOOL someLongVariableName = someLongValue
| someOtherLongValue
| moreLongValues
BOOL someOtherLongVariableName =
someEvenLongerValue;
[someLongVariableName
performSomeAction:someLongArgument]
我目前得到:
BOOL someLongVariableName = someLongValue
| someOtherLongValue
| moreLongValues
BOOL someOtherLongVariableName =
someEvenLongerValue;
[someLongVariableName
performSomeAction:someLongArgument]
要明确的是:
- 我使用的是显式换行,而不是自动换行
- 我希望在编辑时和按return键后立即获得正确的缩进,而不是在运行外部程序(如uncrustify)后
indent\u continue=4
问题
当Xcode重新加载格式化文件时,撤消信息将丢失。我可以从git预提交钩子运行脚本,但我更喜欢更快的结果
另一个缺点是uncrustify中的Objective-C支持并不完美,但似乎别无选择。(也许有一天?)第一个:考虑在语句中使用()。其余部分:考虑重命名:)- 1忽略了问题的前提(这是关于修改压痕深度)。事实上,这甚至是默认设置。可以同时使用这两种设置。例如,先运行
clangformat
,然后在顶部运行uncrustify
,或者反过来运行。我发现clang格式比uncrustify更好地处理一些ObjC事情,例如数组文本中的空格和@property
之后的空格(也许uncrustify也能处理)。是的,自从写了答案之后,clang格式已经成熟了很多。我可能现在只使用它(如果我没有转到Swift…
find . -name '*.[mh]' -print0 \
| xargs -0 git diff-index HEAD -- | grep -v "D\t" | cut -c100- \
| xargs uncrustify -l OC --replace --no-backup -c uncrustify.cfg