Fix code indentation in Xcode

Solution 1:

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

  1. select text
  2. right-click
  3. there's a "Re-indent selection" item in popup menu

In XCode 4 there is one more step:

  1. select text
  2. right-click
  3. Click on "Structure"
  4. there's a "Re-indent selection" and other options in popup menu

Or using the default shortcut:

  1. select text
  2. press ctrl + i

Solution 2:

  1. select text
  2. press Control-I (the default keyboard shortcut)