9

I want to delete some of the default code snippets in XCode 4 because I want the beginning curly brace to start on a new line. I tried the following but XCode 4 does not seem to adhere to the rule.

defaults write com.apple.Xcode XCCodeSenseFormattingOptions -dict BlockSeparator "\\n"

Any suggestions?

Thanks.

David
  • 14,205
  • 20
  • 97
  • 144

2 Answers2

0

The following has worked with my XCode 4 installation:

defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ "BlockSeparator" = "\n" ; }'
Sylvain
  • 1,553
  • 11
  • 15
0

The "defaults write" commands have not worked for me. I got around this by adding a new code snippet with the beginning curly brace on a new line. The next time I typed 'if' I got the built-in completion but since selecting my completion from the drop-down, I now always get my completion.

See more on code snippets here: http://developer.apple.com/library/mac/#documentation/IDEs/Conceptual/Xcode4TransitionGuide/Orientation/Orientation.html#//apple_ref/doc/uid/TP40009984-CH5-SW1

Edit: And a bit more here: http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/Editing/Editing.html#//apple_ref/doc/uid/TP40010215-CH8-SW2

But not very in-depth, the only way I can see to include a replaceable piece of text (e.g. 'conditions' in the 'if' snippet) is by copying from a snippet in the code editor.

  • I used that approach as well, but you'll get 2 suggestions from code completion if your user defined snippet is the same as the default snippet (ex. "If Statement"). – David Mar 22 '11 at 14:32
  • True, but once you use your own snippet, that will be the default snippet. – Jock Findlay Mar 22 '11 at 16:13
  • ...which is fine for me, but it doesn't answer your question, and it probably doesn't help if you're trying to enforce a coding style. – Jock Findlay Mar 22 '11 at 19:17
  • ...and today the default has gone back to Apple's 'if' code snippet. So I'm guessing this has something to do with phases of the moon. This is massively annoying. What made me laugh was the fact that there's an 'Edit' button for the default code snippets - but you can't edit those snippets! Genius! – Jock Findlay Mar 23 '11 at 11:58
  • Yes it's not ideal. I've placed a bounty on it. Hopefully someone will figure it out. – David Mar 23 '11 at 14:36