简体   繁体   English

VSCode 在 html 代码的结束标记中添加空格和斜杠,我该如何禁用它?

[英]VSCode is adding space and slash in ending tag of html code, how can I disable it?

In html file, if I save file with在 html 文件中,如果我用

<br>

it turns into...它变成了……

<br />

I just want first one without slash and space, how can I do it?我只想要第一个没有斜线和空格的,我该怎么做? (I use Prettier if that's the reason) (如果这是原因,我会使用 Prettier)

Found the solution, Prettier was the problem.找到了解决方案,Prettier 就是问题所在。 What I wanted is to我想要的是
get rid of unnecessary slashes in HTML files, but leave auto formatting on other files like js, python...摆脱 HTML 文件中不必要的斜线,但在其他文件(如 js、python...

What I did was...我所做的是...

  1. Go to setting (cmd + ,)转到设置 (cmd + ,)
  2. search prettier搜索更漂亮
  3. on Disable Languages section add "html" (without double quote)在禁用语言部分添加“html”(不带双引号)

problem solved!问题解决了!

The desired functionality seems no longer to be supported by the "Prettier" plugin for VS Code. VS Code 的“Prettier”插件似乎不再支持所需的功能。 To use VS Code formatting for html on saving a file, add要在保存文件时对 html 使用 VS Code 格式,请添加

"editor.formatOnSave": true,
"[html]": {
    "editor.defaultFormatter": "vscode.html-language-features"
}

to your settings.json .到您的settings.json For a more detailed discussion see here .有关更详细的讨论,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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