VSCode的HTML文件格式化程序无法工作

5

我在使用Intellisense时遇到了问题。我已经禁用了所有扩展,但是仍然出现以下提示:

抱歉,没有安装HTML文件的格式化程序

你有什么想法吗?

VS Code版本1.19.1

// Enable/disable autoclosing of HTML tags.
"html.autoClosingTags": true,

// List of tags, comma separated, where the content shouldn't be reformatted. 'null' defaults to the 'pre' tag.
"html.format.contentUnformatted": "pre,code,textarea",

// Enable/disable default HTML formatter
"html.format.enable": true,

// End with a newline.
"html.format.endWithNewline": false,

// List of tags, comma separated, that should have an extra newline before them. 'null' defaults to "head, body, /html".
"html.format.extraLiners": "head, body, /html",

// Format and indent {{#foo}} and {{/foo}}.
"html.format.indentHandlebars": false,

// Indent <head> and <body> sections.
"html.format.indentInnerHtml": false,

// Maximum number of line breaks to be preserved in one chunk. Use 'null' for unlimited.
"html.format.maxPreserveNewLines": null,

// Whether existing line breaks before elements should be preserved. Only works before elements, not inside tags or for text.
"html.format.preserveNewLines": true,

// List of tags, comma separated, that shouldn't be reformatted. 'null' defaults to all tags listed at https://www.w3.org/TR/html5/dom.html#phrasing-content.
"html.format.unformatted": "wbr",

// Wrap attributes.
"html.format.wrapAttributes": "auto",

// Maximum amount of characters per line (0 = disable).
"html.format.wrapLineLength": 120,

// Configures if the built-in HTML language support suggests Angular V1 tags and properties.
"html.suggest.angular1": true,

// Configures if the built-in HTML language support suggests HTML5 tags, properties and values.
"html.suggest.html5": true,

// Configures if the built-in HTML language support suggests Ionic tags, properties and values.
"html.suggest.ionic": true,

// Traces the communication between VS Code and the HTML language server.
"html.trace.server": "off",

// Configures if the built-in HTML language support validates embedded scripts.
"html.validate.scripts": true,

// Configures if the built-in HTML language support validates embedded styles.
"html.validate.styles": true,

谢谢


设置看起来没问题!你能卸载并重新安装VSCode吗? - Arash Motamedi
1
是的,我遇到过这个问题,但有趣的是,我通过切换当前打开的项目并将其切换回来来解决了这个问题。 - Andrej
我也注意到在<script>中不起作用。 - Andrej
1
如果您的VSCode安装一直存在问题,那么值得提交一个bug以便团队可以查看并解决这些问题。请点击VSC窗口右下角的笑脸图标,然后点击“提交Bug”。这将在他们的Github页面上打开一个“新问题”窗口,其中包含有关您的安装的必要信息。 - Arash Motamedi
3个回答

2

我曾经遇到过和VSC版本1.30相同的问题。这些步骤帮助我解决了问题:

  1. 按下Ctrl+K Ctrl+O选择html文件所在的文件夹。
  2. 打开文件资源管理器Ctrl+Shift+E并打开html文件。
  3. 按下Ctrl+Shift+I

完成!我得到了格式化后的代码。


这真的起作用了...而且解决了我遇到的许多其他问题...主要是VS Code没有自动关闭我的标签。谢谢! - Matthew
这是解决方案! - Tagi

1
当我遇到这个问题时,我正在处理一个单独的HTML文件,它不在打开的文件夹或VSC工作区中。当我设置了一个包含该文件的工作区时,HTML格式化程序就可以正常工作了。

谢谢,保存工作区立即解决了我的问题。 - Aaron

0
这种情况发生在我身上,是因为我安装了多个格式化程序,需要配置使用哪个格式化程序。最终,我只卸载了不再需要的一个,问题就解决了。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接