Objective c 在Xcode和Objective C中沿冒号自动对齐列

Objective c 在Xcode和Objective C中沿冒号自动对齐列,objective-c,code-formatting,Objective C,Code Formatting,是否有一个宏或首选项设置可以自动沿Xcode中的列和冒号对齐方法参数 基本上,这是一个扭转局面的捷径: [object methodWithParam:theParam another:theOtherValue something:theSomethingValue else:theElseValue]; 自动转换为: [object methodWithParam:theParam another:theOtherValue

是否有一个宏或首选项设置可以自动沿Xcode中的列和冒号对齐方法参数

基本上,这是一个扭转局面的捷径:

[object methodWithParam:theParam another:theOtherValue something:theSomethingValue else:theElseValue];
自动转换为:

[object methodWithParam:theParam 
                another:theOtherValue 
              something:theSomethingValue 
                   else:theElseValue];

有没有可能在代码完成的情况下实现这一点?换句话说,当我完成一个方法时,它会自动将格式包装成这种样式吗?那么先前存在的代码呢?我可以将插入符号放入方法中,按下键盘快捷键并自动设置参数格式吗?

我认为您正在尝试实现的是以下目标

[object methodWithParam:theParam another:theOtherValue something:theSomethingValue else:theElseValue];
变成更具可读性的东西,例如

[object methodWithParam:theParam
                another:theOtherValue
              something:theSomethingValue
                   else:theElseValue];
这可以通过在每个伪参数之前立即按
return
键来完成。例如,在显示
的位置按return键

[object methodWithParam:theParam <return>another:theOtherValue <return>something:theSomethingValue <return>else:theElseValue];
[objectmethodwithparam:theParam-other:theOtherValue-something-value-other:theElseValue];
如果执行正确,冒号应该对齐

[object methodWithParam:theParam<return>
                another:theOtherValue<return>
              something:theSomethingValue<return>
                   else:theElseValue];
[object methodWithParam:theParam
另一个:theOtherValue
某物:某物的价值
其他:价值];

您还可以将未对齐的线剪切并粘贴到位。(前提是每个参数后面都有一个换行符)或者只需选择文本块并从编辑器菜单中选择“重新缩进”。(我想这就是它所在的位置。不管怎样,这都是control-I。)检查Xcode首选项,确保相关的缩进选项也处于打开状态。