Question

Xcode offers the following options under

Preferences > Text Editing > Indentation > Tab key:

  • In leading white space: Pressing Tab inserts an indentation only at the beginning of a line or following a space.
  • Never: Pressing Tab never causes an indentation.
  • Always: Pressing Tab always causes an indentation.

I checked the documentation for these options (that's what is to the right of the colons) but I still don't understand. What is "an indentation"? What I'd really like is if Xcode wouldn't act like it knows better than me and try reindenting lines of code that were already perfectly indented (I find it often does this inside of blocks - I'll have my code nested one level more than the line before it, and for whatever reason it tries aligning with the colon that starts the block argument, leading to unwieldy long lines, as if Obj-C doesn't have enough of those.)

Can anyone give me examples of how Xcode's behavior will change if I choose each of those options? Will one of those options make Xcode behave/autoindent the way I want it to?

Was it helpful?

Solution

If what you want is:

if Xcode wouldn't act like it knows better than me and try reindenting lines of code that were already perfectly indented

then the "Tab key" indentation setting has nothing to do with what you want.

Instead, try unchecking "Automatically indent based on syntax" and Xcode will stop changing your indentation level.

Alternatively, uncheck { and } under "Automatic indent for:".

See also: Xcode Text Editing Preferences Help: Setting Source Editing and Indenting Preferences

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top