Once I start editing my code and adding for loops or if then statements my code indentation is whacked because the previous code maintains its former indentation instead of
In Xcode 4.6.3, choose Editor
> Structure
> Re-Indent
.
Shortcut: Control + I
(that's 'i', for 'indent')
This works on current selection. If no text selected, choose Edit
> Select All
(⌘+A) and then perform the re-indent.
(I'm more clearly restating the other answers)
Xcode 9.2:
You can select text and press ctrl + i to re-indent code.
You can try my extension Swimat https://github.com/Jintin/Swimat
It support format on selection.
Simple install by brew cask install swimat
You can do this automatically in Xcode 11
These solutions re-indent text to the default xCode behaviors. To change these behaviors, go to xCode (v.4) > Preferences > Text Editing. Then to Indentation Tab.
You can do it in different ways, but these two are the easiest
Using shortcut -> (control)^ + i
Click on "Editor" -> Click on "Structure" -> Click on "Re-indent"