On Feb 4, 2010, at 3:07 AM, Johan Lund wrote:
Go to Preferences > Indentation and choose Automatically insert closing "}"
This should be checked by default do doubt.
It annoys a lot of people (including me). Controversial features that do magic things should be off by default.
Why is it annoying?
Because fairly often when I type "{", I'm not about to add a new block, but changing a single statement into a block. For example, if I have:
if (bad)
return NO;
and I want to add another statement before the return, I click at the end of the first line, type "{" and hit Return, then type the new statement. But if Xcode's closing-brace pref is on, it inserts both braces and what I get is
if (bad) {
}
return NO;
and then I have to delete the line with the close-brace that it added.
It could be argued that if I always used braces around even single-line blocks I wouldn't have this problem, but LET'S NOT GO THERE please :)
It could more successfully be argued that Xcode should realize that the following line is already indented and so it shouldn't insert the close-brace. Maybe it could even insert it after that existing indented line. That would be awesome.
—Jens