How to format code in Xcode?

James Raitsev picture James Raitsev · Jul 1, 2011 · Viewed 202.3k times · Source

I wonder how can I format my code to align it neatly? Does it have a feature similar to Eclipse's ctrlshiftf?

Answer

Piotr Kochański picture Piotr Kochański · Oct 19, 2011

Select first the text you want to format and then press Ctrl+I.

Use Cmd+A first if you wish to format all text in the selected file.

Note: this procedure only re-indents the lines, it does not do any advanced formatting.


In XCode 12 beta:

The new key binding to re-indent is control+I.