Why you should use spaces before your method arguments
Backstory: I had moved the method being called there from a file of NSCalendarDate additions to a file to NSDate additions, so I needed to remove “Calendar”, and wanted to also take out the now-extraneous alignment spacing. One rectangular edit did the job, thanks to using spaces for the alignment.
Of course, you should always use tabs for that initial indent.
November 12th, 2007 at 11:20:53
I hate this formatting style. Takes up huge amounts of space, and a waste of time to both create and maintain. With well named objc selectors this formatting adds nothing to the readability of the code. Hate it, hate it, hate it.
November 12th, 2007 at 11:50:24
Jonathan: I’m not sure whether you’ll hate this more or less:
November 12th, 2007 at 12:07:41
I wrote a BBEdit script a few years ago to align selected lines vertically underneath the first colon in the first selected line. The script could be smarter (occasionally I don’t want it to be the first colon, and it only moves subsequent lines to the right), but it’s been quite handy, and much preferable to enforcing the use of spaces everywhere.
Jonathan: how do you format a tableview datasource method, if not in this style?
November 12th, 2007 at 12:34:28
FWIW, TextMate will perform this formatting if asked. Move the insertion point anywhere inside the brackets of a method call and hit control-shift-Q. TM will detect the boundaries of the method call and format the arguments aligned underneath the first colon. I believe TM will also do the right thing (adding spaces where necessary) if you have used tabs and you want to remove a rectangular slice, but I have not tested that (in recent memory).
November 12th, 2007 at 12:58:57
Xcode will automatically indent it, too, but it uses tabs all the way across until it can tab no more. What it should do is tab to the level of indent of the first line, then switch to spaces the rest of the way (as shown in the screenshot).
Chris Thomas: TextMate is close, in that it uses space from the indent to the argument name, but it also uses spaces for the indent, even though it uses real tabs for indents in all other cases. I’m going to guess that that’s a bug, though.