【问题标题】:VSCode html-files formatter not workingVSCode html文件格式化程序不起作用
【发布时间】:2017-12-21 08:37:34
【问题描述】:

我的智能感知有问题 我已禁用所有扩展,但我仍然得到:

抱歉,没有安装 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 吗?
  • 是的,我有,但有趣的是,我通过切换当前打开的项目并将其切换回来解决了问题
  • 我也注意到
  • 如果您在安装 VSCode 时遇到持续问题,可能值得提交一个错误,以便团队可以调查并希望解决问题。单击 VSC 窗口右下角的笑脸,然后单击“提交错误”。这将在他们的 Github 页面上打开一个“新问题”窗口,其中包含有关您的安装的必要信息。

标签: visual-studio-code


【解决方案1】:

VSC 1.30 版也有同样的问题。这些步骤解决了我的问题:

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

维奥拉!我得到了格式化的代码

【讨论】:

  • 这确实有效......它解决了我遇到的许多其他问题......主要是VS Code不会自动关闭我的标签。谢谢!
  • 这是解决方案!
【解决方案2】:

当我遇到这种情况时,我正在处理一个不在打开的文件夹或 VSC 工作区中的 html 文件。当我设置一个包含该文件的工作区时,html 格式化程序起作用了。

【讨论】:

  • 谢谢,保存一个工作区立即为我解决了这个问题。
【解决方案3】:

这发生在我身上,因为我安装了多个格式化程序,我需要配置要使用的格式化程序。我最终只是卸载了我不再想要的那个,然后它又恢复了工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-18
    • 1970-01-01
    • 2022-07-04
    相关资源
    最近更新 更多