On May 1, 2008, at 3:03 PM, Steve Checkoway wrote:
Roy Lovejoy wrote:
On May 1, 2008, at 11:58 AM, Jason Watts wrote:
Hi folks,
Does anyone know of a way to set the Xcode 3 editor to match the indent of the previous line and nothing else?
no, but I second the insanity-
File a bug report. I did a while back <rdar://problem/5865054> which was marked as a duplicate of <rdar://problem/3721902>. The more people who file reports on this, the more likely they are to address it. Be specific and tell them exactly what it is you want. (I wanted more options similar to how emacs or vim control every aspect of indentation.)
Looking at your bug, I don't see anything that Xcode 3.0 doesn't already support. It looks like the main thing you want is to not indent the case labels inside a switch (and the code for each case). You can get this by setting a user default in Terminal:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ CaseStatementSpacing = ""; }'
For those listening in, here is an example of the formatting Steve would like to see:
-----
void foo( int arg )
{
switch( arg )
{
case 0:
bar();
break;
case 1:
baz();
break;
}
}
-----
Generally Xcode won't do more fancy formatting (it just indents) - except with code completion and when inserting text macros. For the switch statement text macro to match what you like, you'd need the more complex default:
defaults write com.apple.Xcode XCCodeSenseFormattingOptions '{ CaseStatementSpacing = ""; PreExpressionsSpacing = ""; InExpressionsSpacing = " "; BlockSeparator = "\n"; }'
I've included the documentation for this user default at the end of this email. It hasn't yet made into the formal doc set. I hope it does soon, but as always, no promises.
That's nice to hear. :-)
XCCodeSenseFormattingOptions
Description
A dictionary of containing values that get expanded with text macros and code completion.
(Key name = default value)
PreExpressionsSpacing = " "
The spacing between an if, for, while keyword and the opening parenthesis.
InExpressionsSpacing = ""
The spacing inside a parentesized _expression_ (after the opening '(' and before the closing ')').
PreFunctionArgsSpacing = ""
The spacing between function name and the opening parenthesis.
InFunctionArgsSpacing = ""
The spacing inside a parentesized function argument list (after the opening '(' and before the closing ')').
PreCommaSpacing = ""
The spacing before a comma inside function argument list.
PostCommaSpacing = " "
The spacing after a comma inside function argument list.
PreMethodTypeSpacing = " "
The spacing before the parenthesized return type in an Objective-C method declarator.
PreMethodDeclSpacing = " "
The spacing between the parenthesized return type and the method name of an Objective-C method declarator.
InMessageSpacing = ""
The spacing inside a Objective-C message call _expression_ (after the opening '[' and before the closing ']').
PreColonSpacing = ""
The spacing before a colon in an Objective-C method name or message call _expression_.
PostColonSpacing = ""
The spacing after a colon in an Objective-C method name or message call _expression_.
MessageArgSpacing = ""
The spacing between the parenthesized type and parameter name in an Objective-C method declarator.
CaseStatementSpacing = "\t"
The relative indentation of a case keyword inside a switch block. (A tab character means indent by the given indentation width.)
BlockSeparator = " "
The spacing after the parenthesized _expression_ of an if, for, or while statement and the opening '{'.
PostBlockSeparator = "\n"
The spacing after the closing '}' of a block.
FunctionBlockSeparator = "\n"
The spacing after a method or function declarator and the opening '{'.