Add .editorconfig
for consistent code formatting
#122
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Xcode 16 added support for the EditorConfig standard1. This allows a project/repo to specify basic formatting rules so the editor can behave correctly.2
Note
You may need to quit and relaunch Xcode for it to pick up the
.editorconfig
file after switching to a branch where it's present.3The added
.editorconfig
file contains:root = true
: Specifies that this is the top-most .editorconfig file. The file search will stop here.indent_style = space
: Uses soft tabs (spaces) for indentation instead of hard tabs.indent_size = 2
: Sets the indentation to 2 columns.trim_trailing_whitespace = true
: Removes any whitespace characters preceding newline characters.insert_final_newline = true
: Ensures the file ends with a newline when saving.These settings apply to all files in the project (
[*]
).This change make much easier the process of switch between projects that use 2-space and 4-space indentation (what is quite common in your community).
Footnotes
Xcode 16 Beta 2 Release Notes–Source Editor New Features ↩
Inspired by: Add an EditorConfig file ↩
Xcode 16 Beta 2 Release Notes–Source Editor Known Issues ↩