I'm sorry, I know this has been asked before, but the other answers are not doing anything for me.
PhpStorm keeps using 4 spaces for indents, and it is driving me mad. The file is a .php file, and all the settings I know of are correctly set. I have checked these things:
1.) Editor | Code Style | 'Detect and use existing file indents' is not checked (and the file uses 2 spaces anyway)
2.) Editor | Code Style | PHP | 'Tab size' & 'Indent' are set to 2 spaces
3.) I have restarted PhpStorm
4.) I have closed and reopened the file.
5.) My PhpStorm is the most recent version, 2016.3.2
6.) There is only one .editorconfig
in the path of the file, and here are its contents:
# 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
I have also tried removing the last two lines, just out of paranoia, and after restarting PhpStorm again, it did nothing.
As it turn out it's a bug in PhpStorm:
"Tab size" value is ignored if php file isn't started with <?php
i.e.:
#!/usr/bin/env drush
<?php
For those who are interested here is a ticket on PhpStorm's Issue Tracker: https://youtrack.jetbrains.com/issue/WI-34735 -- watch it (star/vote/comment) to get notified on any progress.
Also for newer IDE versions, check if .editorconfig
config-file exists (in any directory of directory-chain leading to your script-file), because Settings from said config-file have higher priority, and will overwrite your IDE settings.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With