html - Visual Studio Code 中没有 HTML 建议

标签 html visual-studio-code

我已经下载了 the latest Visual Studio Code并且正在尝试编写一些 HTML 代码。例如,<div>, <a>, <p>标签。但是,Visual Studio Code 中没有 HTML 建议:

enter image description here

我读过 this article它说:

Visual Studio Code provides basic support for HTML programming out of the box.

但是,我尝试安装 HTML 扩展:

enter image description here

此外,我在 settings.json 中打开了 HTML5 建议文件:

{
    "workbench.colorTheme": "Visual Studio Light",
    "workbench.activityBar.visible": true,
    "editor.multiCursorModifier": "ctrlCmd",
    "window.zoomLevel": 0,
    "html.suggest.html5": true,    
}

然而,HTML、CSS 建议不起作用。

我可以如何根据建议进行编码?

最佳答案

我认为问题在于 Visual Studio Code 未正确检测文件类型。如果您在这些图片中注意到,vscode 已正确检测到我正在通过图标 <> 编写 html 文件。在屏幕右下角的文件名和语言指示器旁边。

File Icons Language indicator

语言指示器很可能会显示 plain text在你的情况下。单击它,屏幕顶部中央应出现一个菜单。然后尝试以下操作:

  1. 启用 Auto Detect .我认为这将是第一个选项。
  2. 选择 Configure File Association for '.html'...
  3. 2也可以通过添加来完成

    "files.associations": { "*.html": "html" }

    到您的设置。

或仅添加到 settings.json (File -> Preferences -> Settings) :

{
     // Configure file associations to languages (e.g. "*.extension": "html"). These have 
     //precedence over the default associations of the languages installed.
     "files.associations":  { "*.html": "html" },
}

关于html - Visual Studio Code 中没有 HTML 建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49842125/

相关文章:

python - 如何将值从 html 传递到 python

javascript - 使用 jQuery 将 SVG 元素插入到 HTML 标记中

带有 CSS 位置的 Javascript 网格

visual-studio-code - 如何在 VSCode 中隐藏目录/函数路径顶部栏

visual-studio-2015 - 在 VS Code 上运行 asp.net core 时,Configuration.GetConnectionString 返回 null,但在 Visual Studio 上运行正常

html - 在 IE 兼容 View 中,开发人员工具显示元素 "style"以及前一个元素的类

javascript - MathML 未呈现并显示在文本区域下方

java - 如何在 Visual Studio Code 中禁用 Java 中未使用的导入的警告?

java - 如何从 Visual Studio Codes 中的其他文件调用 Java 类

regex - 如何使用正则表达式在 Visual Studio Code 中搜索以仅匹配未注释的代码?