tags:

views:

2740

answers:

5
+5  A: 

Read this: XCCodeSenseFormattingOptions

This document describes all the formatting options that auto-complete will use for brace and argument style. Here are mine:

    XCCodeSenseFormattingOptions =     {
    BlockSeparator = "\\n";
    PreMethodDeclSpacing = "";
};
Mike Shields
I think he's talking about the New Project and New File commands, not auto-completion. (At least, I can't imagine putting all my classes in one file using auto-completion to create each one.)
Peter Hosey
new URL:http://developer.apple.com/mac/library/documentation/DeveloperTools/Reference/XcodeUserDefaultRef/100-Xcode_User_Defaults/UserDefaultRef.html
Warren P
@Peter, I was referring to autocomplete and New File/Project, both.
Nocturne
+7  A: 

The New Project and New File commands don't really generate any code; they fill in templates.

You'll need to create your own templates (probably based on Apple's) with the changes you want.

In Xcode 3.1, the stock templates are in /Developer/Library/Xcode. You'll put your modified copies in ~/Library/Application Support/Developer/Shared/Xcode. Pay attention to the subfolders of those folders.

Peter Hosey
A: 

Hey guys any way to change such pointer declaration:

NSString *aString

to such:

NSString* aString

It would save me a lot of time :)

No, because then you don't have a variable associated with the pointer you just declared - what are you calling your new NSString*? And you should post new separate questions as such, not as answers to other questions.
Tim
Sorry problems with editing. I meant this...
Be aware that the second style is potentially dangerous. Whereas this is clear:`NSString *a, b ;`this may be visually confusing:`NSString* a, b ;` (b is not a string pointer but looks like one)And this just plain ugly:`NSString* a, *b ;`
leftspin
+1  A: 

This is something I would like to see too, I don't like the "new school" way of curly braces on the same line as functions or loop control.

When editing and shuffling lines of code around, it's easier to keep everything relevant in one line. Curly braces should only define scope, they're not part of the function definition or program execution (like in if, for etc..).

Modifying all the templates is not really a good solution, but thanks for the info anyway.

Sakari
+5  A: 

For a more specific answer, 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.

Laughing_Jack
worked a treat.. my particular interest was in making auto-generated code like for loops etc have the "right" brace style. How do you find out about these defaults?
Jesse Pepper
http://j.mp/xcode_formatting_defaults (I got that from searching for "xcode user defaults". The first link will lead you there.
Nocturne