Visual Studio 代码中没有 HTML 个建议
No HTML suggestions in Visual Studio Code
我已经下载 the latest Visual Studio Code 并且正在尝试编写一些 HTML 代码。例如,<div>, <a>, <p>
标签。但是,Visual Studio代码中没有HTML建议:
我读过 this article 上面写着:
Visual Studio Code provides basic support for HTML programming out of
the box.
但是,我尝试安装 HTML 扩展:
此外,我在 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 代码没有正确检测文件类型。如果您在这些图片中注意到,vscode 已通过文件名旁边的图标 <>
和屏幕右下角的语言指示器正确检测到我正在编写 html 文件。
在您的情况下,语言指示器很可能会显示 plain text
。单击它,屏幕顶部中央应出现一个菜单。然后尝试以下操作:
- 启用
Auto Detect
。我认为这将是第一个选项。
- 选择
Configure File Association for '.html'...
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" },
}
只需转到“文件 -> 首选项 -> 设置”
搜索“协会”
Check this image
我已经下载 the latest Visual Studio Code 并且正在尝试编写一些 HTML 代码。例如,<div>, <a>, <p>
标签。但是,Visual Studio代码中没有HTML建议:
我读过 this article 上面写着:
Visual Studio Code provides basic support for HTML programming out of the box.
但是,我尝试安装 HTML 扩展:
此外,我在 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 代码没有正确检测文件类型。如果您在这些图片中注意到,vscode 已通过文件名旁边的图标 <>
和屏幕右下角的语言指示器正确检测到我正在编写 html 文件。
在您的情况下,语言指示器很可能会显示 plain text
。单击它,屏幕顶部中央应出现一个菜单。然后尝试以下操作:
- 启用
Auto Detect
。我认为这将是第一个选项。 - 选择
Configure File Association for '.html'...
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" },
}
只需转到“文件 -> 首选项 -> 设置”
搜索“协会”
Check this image