views:

500

answers:

3

For example, I'd like to not indent namespaces in C++ code, but the prefpane doesn't seem to have any place to make a decision of this granularity. Is there some hidden config file or something? Or am I just out of luck?

+4  A: 

Apple's XCode documentation contains a full list of user preferences, many of them that don't have a corresponding UI. I'm not seeing anything that is namespace-specific however, so I think you might be out of luck.

However, I thought I'd pass along the preferences list in case it's useful.

Naaff
+2  A: 

I bypass Xcode's indenting altogether, and have a user script that calls uncrustify on the currently displayed document.

#!/bin/sh
#echo -n "%%%{PBXSelection}%%%"
uncrustify -q -c ~/.uncrustify/sample.cfg -l oc+
#echo -n "%%%{PBXSelection}%%%"

Notes:

  • uncrustify must be in your PATH
  • you may need to adjust the location of your config file
  • if you want to have the new code selected in Xcode, uncomment the two echo statements (this can also be used to make a "Format Selection" script, rather than "Format All"

Script Settings:

  • Input:Entire Document
  • Directory: Home directory
  • Output: Replace Document Contents
  • Errors: display in alert
mmc
A: 

I've also attempted to do this.

The answer is that whoever did the code formatting in XCode appears to be completely unaware that there are languages other than Objective C, or coding styles other than Apple's.

Here's a list of things that one would want to do that can't be done in XCode.

  1. Indent public: or private: just one space.
  2. Indent namespaces zero spaces.
  3. Alternate indentation for arguments NOT relative to the opening parenthesis.

The last one needs a little discussion. Sometimes, a function or method name can be quite long, as well as its first argument, so you want also to be able to indent like this:

someExcitingClass->AVeryLongMethodNameTraLaLaLaLa(
    someLongExpressionOrVariableNameGoesHere,
    anotherNameHere);

Of course, you might want to be extracting subexpressions to make the line shorter, but in real-world code this comes up all the time, and creating subexpressions just to fit everything into a reasonable line length is annoying.

It's a terrible shame and I really have no idea what to do. I personally write in emacs and only dip into XCode as a build system but :-D that's not for everyone.

Tom Swirly