Is it possible to set indent settings in Xcode per project (or per file, even)?

XcodeTabsIndentation

Xcode Problem Overview


Some projects I work in uses tab key settings that equate to 3 or 4 spaces and another wants actual tabs. Another mixes the two depending on directory.

Is there some way to set these settings per project, or even better, per file? If not, does someone have a clever way of dealing with this? (besides "just remember which setting you should use and change it before you start editing")

Xcode Solutions


Solution 1 - Xcode

This seems to have changed with Xcode 4 ... if you click on a file, group or project, amongst the items in the Utilities bar (at the right-hand side, by default) is 'Text Settings'.

Solution 2 - Xcode

You can set indentation per file, group, project, or for all new projects, and for all but per file indentation, new source code files will inherit the indentation settings of the closest parent.

To set indentation per file, select the file in the Project Navigator, and set indentation in the File Inspector ▶ Text Settings.

Xcode indentation per file

To set indentation per group, select the group in the Project Navigator, and set indentation in the File Inspector ▶ Text Settings.

enter image description here

To set indentation per project, select the project in the Project Navigator, and set indentation in the File Inspector ▶ Text Settings.

enter image description here

To set default indentation for new projects, select Xcode ▶ Preferences... ▶ Text Editing ▶ Indentation:

enter image description here

Solution 3 - Xcode

The accepted answer is no longer correct.. as of Xcode 5.1.. which forces you now to Edit "per file" indentation settings via..

enter image description here

enter image description here

Solution 4 - Xcode

Update: This answer only applies to Xcode3. For newer versions, see James Turner's answer.

Yes, go to View > Text > Tab Settings...

There you specify the (file-specific) indentation settings which will be saved in the project.

Solution 5 - Xcode

Actually Alex Gray and James Turner are the most correct - XCode 5.1 allows you to modify the tab/indent from the File Inspector as you mention, but simply highlight the entire project and it will apply to everything within it (i.e. all files).

Solution 6 - Xcode

As of 8.3 you can still select project in the navigator and then change the tab/space indent option in the inspector. Worth mentioning though is that it will only change files in folders that have been added with "Create groups" selected instead of "Create folder references" which is the default.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMichael ChinenView Question on Stackoverflow
Solution 1 - XcodeJames TurnerView Answer on Stackoverflow
Solution 2 - XcodeScott GardnerView Answer on Stackoverflow
Solution 3 - XcodeAlex GrayView Answer on Stackoverflow
Solution 4 - XcodeSteven KramerView Answer on Stackoverflow
Solution 5 - XcodeBVPView Answer on Stackoverflow
Solution 6 - XcodecajjedView Answer on Stackoverflow