VSCode not auto completing HTML

后端 未结 13 1891
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-07 19:32

I\'m having trouble with my new installed Visual Studio Code on Windows 7. On Mac the editor automatically closes html tags but on my Win7 not. I assume there must be some o

相关标签:
13条回答
  • 2020-12-07 20:20

    Press Ctrl + Shift + P to open the command. Then, type Change Language Mode an select HTML or any other desired language.

    0 讨论(0)
  • 2020-12-07 20:21

    If you type

    div.class

    and then press TAB, VS code will automatically close the DIV tag with the given CLASS

    But I think you want to do this operation by pressing the ENTER key.

    In that case, go to your VS Code user setting & paste the following code:

    "emmet.includeLanguages": {
        "javascript": "javascriptreact",
        "vue-html": "html",
        "razor": "html",
        "plaintext": "jade"
    }
    

    Now if you type

    div.class

    & then press the ENTER key, you can see the magic.

    However, the above code will make your VS Code auto-completion with ENTER key not only for normal HTML but also the JSX of React, Vue.js snippets will also cover by this.

    But If you want to do it only for HTML file, just the following line is enough:

    "emmet.includeLanguages": { "javascript": "html" }
    

    Cheers..

    0 讨论(0)
  • 2020-12-07 20:22

    Here is a cool trick (actually an Emmet abbreviation) :

    • write the tag name ­ | e.g. h1
    • add an asterisk after that ­ | e.g. h1*
    • press Tab ­ | (will result in <h1></h1>)

    ­

    PS: This also works for self-closing tags, such as - input , img etc.

    0 讨论(0)
  • 2020-12-07 20:27
    1. Press Ctrl + Shift + P to open the command palette.
    2. Type 'Change Language Mode' in the searcher.
    3. Select 'Change Language Mode'.
    4. Type 'HTML' in the searcher.
    5. And select 'HTML' (it was probably set to 'django-html)
    0 讨论(0)
  • 2020-12-07 20:30

    File > Preferences > Keymaps, Search 'Auto close' and click on install. If it doesn't work, reload the plugin.

    0 讨论(0)
  • 2020-12-07 20:32

    I was experiencing the same problem, then i saw something on my bottom right of vs code.. instead of using HTML, i was using Django-HTML, so i changed the language to html, Boom everything is working fine again.see image

    0 讨论(0)
提交回复
热议问题