How can I indent multiple lines in Xcode?

Viewed 207438

When I select multiple lines of code and want to indent them as usual with TAB key, it just deletes them all. I come from Eclipse where I always did it that way. How's that done in Xcode? I hope not line by line ;)

21 Answers

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.

+ [ and + ] are the equivalents to shift+tab in Xcode.

Multiline Indentation Shortcut key:

ctrl + i

NOTE: Please select codes to Re-indent and press 'control' and 'i' on your mac.

Another way to quickly reformat indenting is a quick cut and paste. +x and +v. I often find it faster than +[ or +] as you can do it with one hand (versus two) and it will reformat to the correct indent level in one shot.

For code indentation first select the lines of code then press:

command + alt + [

command + alt + ]

Select the lines and press Ctrl+i from keyboard.

You will have the lines indented.

Tab for Indent SHIFT + Tab Re-indent

Related