Fix code indentation in Xcode

xcode

Solution

Before Xcode 9 (for Xcode 9 see default shortcut below)

- select text

- right-click

- there's a "Re-indent selection" item in popup menu

In XCode 4 there is one more step:

- select text

- right-click

- Click on "Structure"

- there's a "Re-indent selection" and other options in popup menu

Or using the default shortcut:

- select text

- press ctrl + i

Problem

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 adjusting automatically. In Visual Studio you can highlight code and select 'format selection' to fix these issues - is there anything similar in Xcode?

Original source

Related problems