PhpStorm 不会使用 2 个空格进行缩进

Rai*_*nch 4 phpstorm

抱歉,我知道以前曾问过这个问题,但其他答案对我没有任何帮助。

PhpStorm 一直使用 4 个空格来缩进,这让我抓狂。该文件是一个 .php 文件,我所知道的所有设置均已正确设置。我已经检查过这些事情:

1.) 编辑 | 代码风格| 未选中“检测并使用现有文件缩进”(并且文件无论如何都使用 2 个空格)

2.) 编辑 | 代码风格| PHP | “制表符大小”和“缩进”设置为 2 个空格

3.) 我已经重新启动了 PhpStorm

4.) 我已关闭并重新打开该文件。

5.) 我的PhpStorm是最新版本,2016.3.2

6.) 该文件的路径中只有一个.editorconfig,其内容如下:

# Drupal editor configuration normalization
# @see http://editorconfig.org/

# This is the top-most .editorconfig file; do not search in parent directories.
root = true

# All files.
[*]
end_of_line = LF
indent_style = space
indent_size = 2
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[composer.json]
indent_size = 4
Run Code Online (Sandbox Code Playgroud)

我还尝试删除最后两行,只是出于偏执,再次重新启动 PhpStorm 后,它什么也没做。

Laz*_*One 5

事实证明这是 PhpStorm 中的一个错误:

如果 php 文件不是以<?phpie 开头,则忽略“制表符大小”值:

#!/usr/bin/env drush
<?php
Run Code Online (Sandbox Code Playgroud)

对于那些对此感兴趣的人,可以在 PhpStorm 的问题跟踪器上找到一张票: https: //youtrack.jetbrains.com/issue/WI-34735 - 观看它(star/vote/comment)以获取有关任何进展的通知。

另外,对于较新的 IDE 版本,请检查.editorconfig配置文件是否存在(在通向脚本文件的目录链的任何目录中),因为所述配置文件中的设置具有更高的优先级,并且会覆盖您的 IDE 设置。