Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhpStorm removing tabs/spaces on every save

Tags:

phpstorm

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

like image 783
Zenel Shabani Avatar asked Dec 04 '16 18:12

Zenel Shabani


3 Answers

I recently experienced the behavior that trailing spaces got removed everywhere although the option Settings/Preferences > Editor > General > Strip trailing spaces on Save was set to Modified Lines. Setting the option to None didn't help nigher.

The reason for that was, that I had installed the JetBrains IDE plugin EditorConfig. In the root of my (PHP-) project I had a .editorconfig file with the setting trim_trailing_whitespace = true. Setting that to false, fixed the issue.

like image 66
LarS Avatar answered Oct 22 '22 19:10

LarS


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) or disable such support in the IDE (Settings/Preferences | Editor | Code Style | Enable EditorConfig support)

like image 20
LazyOne Avatar answered Oct 22 '22 19:10

LazyOne


PhpStorm 2021.2.3

Just Settings/Preferences > Editor > General

  • scroll down to On Save
like image 2
bagsmode Avatar answered Oct 22 '22 19:10

bagsmode