tags:

views:

652

answers:

3

Is there anyway to format the code in Xcode like you can do in Eclipse or Netbenas. I have not found any option in menu, is there any hot key for this or its simply not in Xcode?

+1  A: 

Select some text and then: Edit->Format->Re-Indent

You can bind this to a hotkey in the preferences.

nall
This barely counts as code formatting.
Stefan Kendall
Fair enough, but AFAIK it's the closest thing Xcode has.
nall
Not really. See the post that's been upvoted.
Stefan Kendall
This is the closest thing Xcode has to built-in formatting support.
nall
+4  A: 

Other than re-indentation (Edit > Format > Re-Indent), not really. However, Xcode does have support for scripts (the menu to the right of the Window menu), so you could conceivably write a script that formats your code how you like it.

Edit: here are some links that touch on this subject:

http://hackertoys.com/2008/09/18/adding-a-code-beautifier-script-to-xcode/ http://8020world.com/jcmendez/2006/11/geeky-stuff/software/adding-a-script-menu-to-xcode-to-reformat-code-using-astyle/

Dave DeLong
+1  A: 

My personal fav PrettyC wantabe is uncrustify: http://uncrustify.sourceforge.net/. It's got a few billion options however so I also suggest you download UniversalIndentGUI_macx, (also on sourceforge) a GUI someone wrote to help set the options the way you like them.

geowar