Search code examples
phpstorm

PhpStorm removing tabs/spaces on every save


I just updated to PhpStorm 2016 and I noticed that suddenly every time I press Ctrl + S to save the file it removes the spaces/tabs that I pressed to continue writing after testing this bit of code.

Pleas help, this is very annoying for me, since I save my file after every line of code.

Here is a screenshot when I'm about to save, so after hitting Ctrl + S the text cursor will move all the way to the left, deleting all spaces & tabs.

enter image description here


Solution

  • You need to disable Settings/Preferences | Editor | General | Remove trailing spaces on: option.

    enter image description here

    (NOTE: in older IDE versions you may have just a drop down box and have to select the None option there)


    P.S. Please note that if you have .editorconfig files in your project then corresponding setting from there (trim_trailing_whitespace) will overwrite such IDE setting. It is expected as it's the whole nature of such files.

    If you do not like that then either edit your .editorconfig file accordingly (https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#current-universal-properties -- i.e. have trim_trailing_whitespace = false) or disable such support in the IDE (Settings/Preferences | Editor | Code Style | Enable EditorConfig support)