Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Automatic column align along colons in Xcode and Objective C

Is there a macro or preference setting that would automatically align method parameters along the columns and colons in Xcode?

Basically a shortcut to turn this:

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

automatically into this:

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

Is it possible to get this working with code completion? In other words when I tab complete a method it would automatically wrap the formatting into this style? And what about preexisting code? Can I put my caret inside a method, press a keyboard shortcut and auto format the parameters?

like image 484
alex Avatar asked Jun 17 '26 00:06

alex


1 Answers

What I think you are trying to accomplish is turning the following

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

Into something more readable such as

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

This can be accomplished by pressing the return key immediately before each pseudo-argument. For example, press return where <return>is shown.

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

If executed properly, the colons should align.

[object methodWithParam:theParam<return>
                another:theOtherValue<return>
              something:theSomethingValue<return>
                   else:theElseValue];
like image 144
Brian Tracy Avatar answered Jun 22 '26 15:06

Brian Tracy