简体   繁体   中英

VS Code - How to stop it deleting whitespaces?

I am using Microsoft's VS Code to edit css, html and ts files that are shared by my team on a VSTS Git repo. However, my VS Code keeps removing empty/whitespaces that my colleagues added when I save any change (Image below) and this screws up the whole Git Diff part, as almost every single line of code shows as a diff. I tried to disable every single config setup but nothings works:

在此处输入图像描述 在此处输入图像描述 在此处输入图像描述

It seems you have trailing whitespace enabled in User Preferences too.

I'd suggest opening your configuration file of VSCode using Ctrl Shift P or Cmd Shift P in Mac and then go to Open User Settings .

I'm sure the next line is around there somewhere, delete it or change it to false .

files.trimTrailingWhitespace": true

At the end, what was causing my problem was the extension: EditorConfig for VS Code

This plugin attempts to override user/workspace settings with settings found in .editorconfig files. No additional or vscode-specific files are required. As with any EditorConfig plugin, if root=true is not specified, EditorConfig will continue to look for an .editorconfig file outside of the project.

I believe, it was overriding the options I selected inside of VS Code (such as files.trimTrailingWhitespace: false ). So, no setup change I was making was actually being applied.

就我而言,来自 lonefy 的JS-CSS-HTML Formatter扩展导致了这个问题。

Editor › Comments: Ignore Empty Lines ——>choose :false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM