Similar questions have been asked before, but they didn't help me with what I'd like to do:
I want to re-format existing Objective-C code (several hundred files). For pure Apple-style formatting, uncrustify seems to do what I want. But for a few projects, I need a different style that I haven't found out how to configure uncrustify for. In this style, long method calls look like this (please refrain from discussing whether you like that style or not; do not suggest to use a different style):
[self
longMethod:arg1
withLots:arg2
ofArguments:arg3
aBlock:^{
[self doSomething];
}
andAnotherBlock:^{
[self doSomethingElse];
}
];
This wrapping is done when the method call would exceed a line length of 80 or 100 characters. Each line is indented by one level and contains exactly one argument and the selector part up to the corresponding :
. The lines thus are not colon-aligned.
No wrapping is done if the line length is below 80 or 100 characters:
[self shortMethod:withAnArgument];
Is there a code formatter that can be tweaked to support this style? If so, which and more importantly, how?
Clang format can be used to format code in any number of styles. You can even specify the exact options you desire, or use one of several "standard" styles.
There is an XCode plugin as well.
No, I do not think that there is code formatter for this style. You can use clang's Lib Tooling to do the job. Yes, you have to build you own tool using it. But developing your own tool is the usual way, if you want to do something very unusual.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With