Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm reformat - how do I disable removing spaces in empty lines?

When reformatting a file, phpstorm replaces empty lines with whitespace to just empty lines, e.g. ^[tab][tab]$ to ^$. How do I disable this?

like image 362
Fluffy Avatar asked Jun 03 '14 11:06

Fluffy


People also ask

How to remove whitespace in PyCharm?

Newer PyCharm (2020 and beyond) have slightly different answer than Code-Apprentice's. Go to File->Settings->Editor->General, and then scroll down to Save Files section. The drop down Strip trailing spaces on Save for: is there. You can select None if you don't want any stripping in no circumstances.


2 Answers

You cannot -- http://youtrack.jetbrains.com/issue/IDEA-73161

I was thinking that disabling stripping whitespace characters altogether would do the job:

By changing Settings | Editor | Strip trailing spaces on Save (which nowadays has Modified Lines option)

but apparently it only works on "Save".

Related tickets:

  • http://youtrack.jetbrains.com/issue/IDEA-99173

Now you can do that on code reformat as well:

  1. Settings/Preferences
  2. Editor | Code Style
  3. $language$ | Tabs and Indents | Keep indents on empty lines check box

(this option was introduced after this answer was provided: https://youtrack.jetbrains.com/issue/IDEA-103941#comment=27-807213)

like image 181
LazyOne Avatar answered Oct 08 '22 11:10

LazyOne


I find solution in opposite topic: Configure editor to remove whitespaces in blank lines.

It works in WebStorm, and should work in PHPStorm as well:

Settings | Editor | Code Style | PHP | Tabs and Indents (tab) | Keep Indents on Empty Lines" (check box)

like image 2
coderaiser Avatar answered Oct 08 '22 11:10

coderaiser