Visual Studio Code trimTrailingWhitespace set to false is still trimming whitespace on save
Asked Answered
D

0

6

I've been using VS Code for about three months now.

I have this issue where I update one single line of code in a .js file (also happens with some .css files) and my diff tool tells me that there are 100s of changes.

Apparently the files.trimTrailingWhitespace: false is not doing anything at all as it continues to trim whitespace on the file(s) on save.

These are all the settings I have been overridden on my user config:

"editor.trimAutoWhitespace": false,
"files.trimTrailingWhitespace": false,
"editor.formatOnSave": false

Nothing seems to be taking.

Also, I don't have any extensions that format my code (as far as I know).

Running VS Code for Mac v1.16.1 (latest? as of today)

Update

So, it looks like any other app (Sublime, Brackets, Atom) or even a git repo tool (like Gitlab) modifies either whitespaces or line-breaks on this file...

I even thought that maybe it was a platform-related issue (gitlab's modifications to the file, kinda hinted that it wasn't platform-related) but opening the file in Sublime on Windows did the same thing... whitespaces or line-breaks get reformatted on save. I still don't know what exactly is going on on save.

Dhar answered 18/9, 2017 at 16:50 Comment(9)
Do you have the editorconfig extension installed? Is there a workspace setting overriding your user setting?Rana
Why wouldn't you want it to trim trailing whitespace? What specific application would you want that for?Digitalize
@RobLourens no workspace config. Only user config. I don’t think I have that extension. I will check tomorrow for it. Thanks for the insight.Dhar
@Digitalize it’s a '.js' file. But I see that happening a lot when opening other files too. I don’t want it because it triggers massive lists of changes on my commits to git. One line change is triggering a git commit of 1500+ changes. I understand and agree with you that the trimming is often a good thing, but I don’t like it when my code editor changes things I didn’t ask it to do so. Also, that’s why there’s a setting, which is being ignored.Dhar
Fixing all of the trailing whitespace issues is never a bad option. Fix it once, and then enforce the code style in the future.Digitalize
@Digitalize I understand the benefits, but it’s not the point here. The application is not doing what I am asking it to do. I don’t want it modifying stuff.Dhar
@RobLourens, I just checked and I do not have the editorconfig extension installed at all.Dhar
@Digitalize useful to have it turned off for pug else your inline anchors run together with the previous word.Belanger
Can you still reproduce this issue? Did you have a .vscode/settings.json file in your workspace folder? (settings in such a file can override the user settings)Reserve

© 2022 - 2024 — McMap. All rights reserved.