PHP indents stuck on 4 spaces
I have all my indentation settings for PHP set to 2 spaces, and I have indentation auto-detection turned off, but PHP still always uses 4 spaces, and it shows in the bottom right. I have no .editorconfig either. I've searched everywhere and tried every solution, including fully reinstalling PHPStorm.
Only other thing I can think of is a broken settings file somewhere, but I want to confirm that there's no other solution before I fully wipe my settings.
Please sign in to leave a comment.
Hi,
Is it reproducible on new files/new project too?
Would it be possible to share your code style export? (Settings/Preferences | Editor | Code Style > Scheme > Export > XML)
Hmm, yeah okay it's only happening in this project.
This is my Default code style export:
The Project one was empty.
Thank you for your reply.
Does it happen for all files in this specific project including newly created ones too?
Could you please share the affected project `.idea` folder? You may do that privately via our JetBrains Upload services (just let me know the upload id):
https://uploads.jetbrains.com
I'm having the same problem with just one project and it is triggered every time when I create a new file. If I close the IDE and open it again, it shows and uses the correct indent - 2 spaces and that's until the next new file.
Is there any chance that affected files have mixed HTML/PHP code? If this is the case, you might be experiencing the following issue:
https://youtrack.jetbrains.com/issue/WI-59720/HTML-indent-settings-are-used-in-PHP-HTML-mixed-code
In my case it's JavaScript - React JSX and it's 100% reproducible. Also, this was introduced in some of the last 2-3 updates of the IDE.
Do you have an `.editorconfig` file in this specific project?
This is still a problem, and it happens editing existing files, will not format to 2 spaces.
Tried formatting with
NOTE that Php is set to 4 spaces, HTML and JS are set to 2.
Potential solution: I experienced this today and it seems like there is a persistent indent setting on existing files that doesn't get cleared when you change the project settings. If you look at the bottom right corner of the window there is a label which indicates the current file setting (eg “4 spaces”), marked with an asterisk if it doesn't match the project value.
Right-clicking on this label allows you to apply the project setting to the file and reformat it accordingly.