Xcode: Adjusting indentation of auto-generated braces?

Debajit picture Debajit · Dec 25, 2008 · Viewed 17.8k times · Source

Code auto-generated by Xcode seems to have the opening brace on the same line by default:

@interface Controller : NSObject {

}

I'd like the opening brace on a line of its own, like this:

@interface Controller : NSObject 
{

}

This applies in general to any method / class auto-generated by Xcode. In Xcode preferences I have "Indent solo { by" set to 0: alt text

How can I fix this?

Answer

Laughing_Jack picture Laughing_Jack · May 7, 2010

For Xcode 3.x, you can use the following: If you open up a terminal session and enter
defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }'
it will start new blocks of code on a new line. Note that you will have to restart XCode if you have it opened in order for the new defaults to be read and used.

For Xcode 4.x to 6.x (current) I suggest you use Snippet Edit as a handy tool for editing the snippets that define the Xcode autocompletion. At the current time it's free and works great.