How can I indent multiple lines in Xcode?
The keyboard shortcuts are ⌘+] for indent and ⌘+[ for un-indent.
- In Xcode's preferences window, click the Key Bindings toolbar button. The Key Bindings section is where you customize keyboard shortcuts.
Select your code to reindent, then Go to
Editor -> Structure -> Re-Indent
⌘ + [ and ⌘ + ] are the equivalents to shift+tab in Xcode.
Here are the shortcuts, to format the code in XCode
-
Format entire code (entire class/controller)
Select the entire code and press control+I on mac to format your code.
-
Format particular block of code
Select the code and press:
- ⌘+] for right move (indent)
- ⌘+[ for left move (un-indent)
Note: as per @JavierGiovannini sugesstion you can do using Editor Menu option
- Select your code and navigate to Editor > Structure > Re-Indent
First, select all code using command
+a
Second, hold key ctr
and then press i
the whole selected code will nicely indent.