VScode 在保存时自动添加新行 [英] VScode automatically adding new lines on save
问题描述
我在使用 vscode 时遇到了这个问题,每当我保存 HTML 文件时,它都会自动添加新行.这不是因为任何扩展,因为我通过启动不带扩展的 vscode 进行了测试.下面是我想说的
I am facing this issue with vscode that whenever I am saving an HTML file it automatically adds the new lines. It is not because of any extension because I tested by starting vscode without extension. Below is what I am trying to say
这就是我想要的:
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
<li><span>X</span></li>
这就是当我按下 ctrl-s 时 vscode 将它变成的
And this is what vscode turns it into when I hit ctrl-s
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
<li>
<span>X</span>
</li>
我也关闭了自动换行并尝试了各种设置,但还没有成功.有人知道吗?
I have turned word-wrap off as well and tried all kinds of settings but no luck yet. Anyone have any idea?
推荐答案
根据 VSCode 上的这个问题GitHub,从 1.8 开始有一个选项:
According to this issue on VSCode's GitHub, There is an option for that since 1.8:
"files.insertFinalNewline": true
为了彻底,您可以使用所有这三个设置来执行您通常需要的大部分基本格式:
And to be thorough, you can use all of these three settings to do most of basic formatting you usually need:
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
注意:我知道这可能与 op 的描述不符,尽管这个问题是 在 DuckDuckGo 上搜索 vscode 在保存时追加新行.所以我觉得有必要添加这个答案.
这篇关于VScode 在保存时自动添加新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!