#21076·yii2

The default .editorconfig forces 4-space indentation in Zed

Author: nucklearprojectCreated Aug 25, 2026Updated Aug 28, 2026
Labelsstatus:under discussion

Description

What steps will reproduce the problem?

  1. Create a new Yii2 Basic Application using Composer:
bash
composer create-project --prefer-dist yiisoft/yii2-app-basic basic
  1. Open the newly created project in Zed.

  2. Configure Zed to use 2 spaces, for example in .zed/settings.json:

json
{
  "tab_size": 2,
  "hard_tabs": false,
  "auto_indent": "syntax_aware"
}
  1. Open a PHP file and press Tab.

Despite the Zed configuration specifying 2 spaces, indentation is inserted using 4 spaces.

Expected behavior

The editor should use the configured 2-space indentation.

Actual behavior

PHP files use 4-space indentation.

This can be particularly confusing because the Zed configuration appears to be correct, and the behavior also occurs when no formatter is configured.

For example, setting:

json
"formatter": null

prevents formatting entirely, but pressing Tab still inserts 4 spaces.

Cause

The Yii2 Basic Application template includes this .editorconfig:

ini
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.js]
indent_size = 2

[*.md]
trim_trailing_whitespace = false

[*.php]
ij_php_space_before_short_closure_left_parenthesis = false
ij_php_space_after_type_cast = true

[*.yaml]
indent_size = 2

[*.yml]
indent_size = 2

[*.xml.dist]
indent_size = 2

[LICENSE*]
indent_style = unset
indent_size = unset

The important part is:

ini
[*]
indent_size = 4

There is no PHP-specific indent_size, so PHP inherits the global value of 4.

Changing it to:

ini
[*]
indent_size = 2

immediately fixes the indentation behavior in Zed.

Why this is confusing

The Yii2 project also includes JetBrains-specific ij_php_* settings, which suggests that this file is primarily intended to provide editor configuration for the project.

However, .editorconfig is also consumed by editors such as Zed. Therefore, the global:

ini
indent_size = 4

can silently override the user's expected editor indentation.

In my case, this resulted in several hours of troubleshooting because the Zed configuration itself was correct.

Possible solution

Consider either:

  1. documenting that the Yii2 template intentionally uses 4-space indentation and that .editorconfig will override editor-specific indentation settings, or
  2. adding a PHP-specific setting if the intended PHP indentation differs from the global setting, or
  3. reconsidering whether the default .editorconfig should impose a specific indentation size on all editors.

At minimum, it would be helpful to mention this in the Yii2 documentation so users who configure their editor for 2-space indentation can quickly identify .editorconfig as the source of the behavior.

This is especially relevant for editors that automatically honor .editorconfig, such as Zed.