Customizing Xcode Text Macros

Students in our classes often ask how to customize Xcode’s text macros for block structured statements (e.g., method and function bodies, bodies of if, for, and while statements, etc.) in order to push the opening curly brace to the next line. Here’s a little command-line fu using OS X’s defaults mechanism:

defaults write XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }'

This tells Xcode to use a newline character as the ‘block separator’ between the opening curly brace and whatever preceded it.


1 comment so far

  1. Scott Gardner on

    Does not work in Xcode 4. I also tried…

    defaults write XCCodeSenseFormattingOptions ‘{ “BlockSeparator” = “\n” ; }’

    (note the “dt”)

    …which also did not work. Any ideas?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: