I DON'T want trailing withe spaces removed on save.

I have try everything I don't want trailing withe spaces removed on save.

I tried on General > other Strip railing spaces on save > none,   on Code >keep white spaces.

none of them work. Every-time I save a file it removes the white spaces at the end of a line.

 

is this a Bug?  any one?

 

thanks

 

 

 

30 comments
Comment actions Permalink

Do you have .editorconfig in your project? What IDE version do you use?

1
Comment actions Permalink

 I don't have it.... is it a plugin? My IDE version is 2017.14

0
Comment actions Permalink

Sorry I do have it :/

0
Comment actions Permalink

It's a configuration file with code style settings. Is there anything about space trimming? 

0
Comment actions Permalink

if I keep the cursor on the line it will keep the trailing white spaces. But if I move the cursor to another line it will delete the spaces on save

0
Comment actions Permalink

Sorry, I didn't get if you have .editorconfig file in your project or just EditorConfig plugin?

Is the option "Enable EditorConfig support" enabled in Settings/Preferences | Editor | Code Style? Does the problem persist if you disable it? 

1
Comment actions Permalink

I don't have "EditorConfig support" option under Settings/Preferences | Editor | Code Style :/

0
Comment actions Permalink

1) If you don't have such option, it means that EditorConfig plugin is disabled.

2) Does the problem persist in a brand new project? 

Please provide a sample project where the issue can be reproduced as well as your IDE's settings (File | Export Settings). You can upload these files to https://uploads.services.jetbrains.com/. Once uploaded, please let me know their names.

 

 

0
Comment actions Permalink

Still happens in a new project.

Files uploaded, the name of files are test and  settings

Many thanks 

0
Comment actions Permalink

Thank you for the provided information!

So first of all, the project has no files, so I can't see how you reproduced the problem there. Moreover, in your settings I see that the option "Strip trailing spaces on Save" is set to All. 

So please collect the information more attentively:

1) the project with at least one file where you reproduced the issue.

2) the correct settings

3) a screenshot of Editor | General | Other

4) a screenshot of the whole page of Editor | Code Style

5) idea.log after reproducing the problem (Help > Show log in...)

2
Comment actions Permalink

Junaid - I love you man! Thank you!!! 

0
Comment actions Permalink

Thanks, Junaid. This works for me.

0
Comment actions Permalink

Hey! I'm sorry for resurrecting a 2 year old thread, but the link provided by Juniad is not working anymore. Can anyone post the solution directly in this thread or smth please?

0
Comment actions Permalink

@Nathan Pbombana

I have no idea what was written there (in no longer working link).

In any case: Settings/Preferences | Editor | General | Strip trailing space on Save -- adjust to whatever your needs are

 

NOTE: If you have .editorconfig file in your project, such option can also be controlled via that file. This file can provide more granular control over what files are affected by those settings.

Settings from .editorconfig file will OVERWRITE IDE settings (the whole nature of such files), so if you have such files in your project and such instruction there, you will have to either disable the EditorConfig for this project or disable plugin completely (if you do not care about it at all).

3
Comment actions Permalink

In editorconfig, the setting in question is trim_trailing_whitespace. Even if it's not present at all, IntelliJ seems to assume a default value of true and trims the lines in the complete file.

0
Comment actions Permalink

>Even if it's not present at all, IntelliJ seems to assume a default value of true

if it's not there, IDEA doesn't assume anything, it uses Strip trailing space on Save option

0
Comment actions Permalink

I haven't checked in IDEA but in Rider 2019.3.4, if the trim_trailing_whitespace option is not present, it strips always all lines of a modified file even if Strip trailing space on Save is set to none.

0
Comment actions Permalink

Whatever I do off the things mentioned above, AndroidStudio always removes my empty lines on save!

This is very annoying!

0
Comment actions Permalink

PHPSTORM always trimming white spaces at end of line it's very annoying when double spaces of markdown are "break line" 

 

 

 

my .editorconfig file is:

0
Comment actions Permalink

When does it happen - on re-formatting, on saving, or?

0
Comment actions Permalink

Later I'll try if it happen during reformatting

0
Comment actions Permalink

Do you have any on-save actions configured (run Prettier/ESlint on Save, files watchers, etc.)?

0
Comment actions Permalink

during reformatting spaces stay in place, eslint is disabled, prettier not installed, any other actions on save not found

 

0
Comment actions Permalink

Since the IDEA-105040 fix trailing spaces are never stripped in .md files on Save regardless of settings... So it must be some other tool that modifies your files

0
Comment actions Permalink

what  other info I can send to You, or how can i check what is triggered during saving ?

0
Comment actions Permalink

No idea, sorry... It's not necessary a tool that is started from the IDE, can be some external file watcher

Can you reproduce the issue in a new project, BTW?

0
Comment actions Permalink

I tried with a brand new project with no files in it, copied in the directory of the project an existing md file with trailing double spaces, opened it and saved it after adding a line with random text in the file : line endings ARE trimmed of trailing spaces.

0
Comment actions Permalink

Just chipping in here to say that I had this problem too. Make sure you check the .editorconfig file (probably at your project root).

Look for the line

trim_trailing_whitespace = true

There may be more than one as different sections can have the same rule for different types of files. If you never want to strip trailing whitespace from any file make sure you find all instances of this rule and set it to false

trim_trailing_whitespace = false
0

Please sign in to leave a comment.