On save new line added to end of file. How stop this?

I did a search in the forum for this but did not get any results back.  I looked in settings but there are so many I am not sure where to look.

When I save a file, PhpStorm adds a new line to the end of the file.  How do I stop this from happening?

Thanks.

7 comments

@Dragos Rosu

Works just fine here. Don't know other options that could do such thing (unless some another tool/plugin does it).

The only thing I can think of ... 1) do you have .editorconfig files in this project?.. and 2) Do you have EditorConfig Support plugin installed? Settings from such file will override similar option from IDE Settings/Preferences (the nature of such files).

5

In PHP Storm 2018.2.5 

File | Settings | Editor | General --> Other ---> Ensure line feed at file end on Save 

4

Hi there,

Some tip first: If you do not know if some configuration option is available and where it located in Settings window, then use Search box in Settings window (the very first thing on left top corner) -- extremely helpful feature in such situations. If found nothing -- try to use another spelling/naming (sometimes the option can be named differently to what particular person may expect).

Back to your issue -- untick the following option: File | Settings | Editor --> Ensure blank line before end of file on Save
Try searching for "blank line" on Settings screen and see how it works.

2

That was it, thank you kindly @Andriy Bazanov!

I was hating Webstorm for a while now for this "hidden bug". Someone commited some editor configuration in our repository and that broke it up.

 

Thank you kindly!

2

You either enable it or disable it, it still adds that line on Windows 7 / Windows 10 and Ubuntu 14 machines. Why is that??

1

Note that the Editorconfig plugin may override this setting if you .editorconfig file has:

insert_final_newline = true
1

Let me add that if there is already a blank line at the end of the file it does not keep adding new lines.  If there is NO blank line then when I save the file a new blank line is added.  I actually want some files to have no blank line at the end.

Thanks.

0

Please sign in to leave a comment.