首页 > 解决方案 > 使用链接的css文件在html文件中没有ctrl +空格的VS Code自动完成

问题描述

我对全新安装 vs 代码有疑问。我是第一次使用它,对我来说,一件很烦人的事情是,当我在我的 html 文件中写入时:

<div id

然后按 Enter 它需要我

<div id=""

但我必须 ctrl+space 才能看到 CSS 的自动完成

id 喜欢键入和自动完成自动启动。

尝试这样的用户设置和工作区设置:

{
  "editor.quickSuggestions": {
    "other": true,
    "comments": true,
    "strings": true
  },
  "editor.wordBasedSuggestions": true
}

对我不起作用。

请帮忙

这是我的新工作区配置

    {
  "editor.quickSuggestions": {
    "other": true,
    "comments": true,
    "strings": true
  },
  "editor.wordBasedSuggestions": true,
  "emmet.triggerExpansionOnTab": true,
  "editor.wordBasedSuggestions": true,
  // true is the default already
 "emmet.showAbbreviationSuggestions": true,

 "editor.snippetSuggestions": "top",
 "emmet.showSuggestionsAsSnippets": true
}

这让我输入 div.classname 并显示我的 css 类列表,但 div#idname 不起作用:) 不知道该怎么做

标签: visual-studio-code

解决方案


在这里使用 emmet 扩展,它会容易得多。

div#myId

然后entertab或将扩展为:

<div id="myId"></div>

要使用tab完成,true请在您的设置中将其更改为:

"emmet.triggerExpansionOnTab": true,

您应该无需执行Ctrl-即可看到 emmet 建议space。试试这些设置:

// true is the default already
 "emmet.showAbbreviationSuggestions": true,

"editor.snippetSuggestions": "top",
"emmet.showSuggestionsAsSnippets": true,

此外,这些设置对您的问题没有影响:

[在字符串或评论中输入时会显示建议]:

 {
      "editor.quickSuggestions": {
        "other": true,
        "comments": true,
        "strings": true
      },

[建议也将包括文档中的所有文本 - 通常会使您的建议列表变得混乱,但无论如何您都想要它]:

    "editor.wordBasedSuggestions": true

推荐阅读