[英]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.我正在使用 Microsoft 的 VS Code 编辑我的团队在 VSTS Git 存储库上共享的 css、html 和 ts 文件。 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.
但是,我的 VS Code 不断删除我的同事在我保存任何更改时添加的空白/空格(下图),这搞砸了整个 Git Diff 部分,因为几乎每一行代码都显示为 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 .我建议在 Mac 中使用Ctrl Shift P或Cmd Shift P打开您的 VSCode 配置文件,然后转到Open User Settings 。
I'm sure the next line is around there somewhere, delete it or change it to false
.我确定下一行在某处,删除它或将其更改为
false
。
files.trimTrailingWhitespace": true
At the end, what was causing my problem was the extension: EditorConfig for VS Code最后,导致我问题的原因是扩展名: VS Code 的 EditorConfig
This plugin attempts to override user/workspace settings with settings found in .editorconfig files.
此插件尝试使用 .editorconfig 文件中的设置覆盖用户/工作区设置。 No additional or vscode-specific files are required.
不需要额外的或特定于 vscode 的文件。 As with any EditorConfig plugin, if root=true is not specified, EditorConfig will continue to look for an .editorconfig file outside of the project.
与任何 EditorConfig 插件一样,如果未指定 root=true,EditorConfig 将继续在项目之外寻找 .editorconfig 文件。
I believe, it was overriding the options I selected inside of VS Code (such as files.trimTrailingWhitespace: false ).我相信,它覆盖了我在 VS Code 中选择的选项(例如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 Editor › Comments: Ignore Empty Lines ——>选择:false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.