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
Press Ctrl + Shift + P
to open the command.
Then, type Change Language Mode
an select HTML
or any other desired language.
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..
Here is a cool trick (actually an Emmet abbreviation) :
h1
h1*
<h1></h1>
)
PS: This also works for self-closing tags, such as - input
, img
etc.
File > Preferences > Keymaps, Search 'Auto close' and click on install. If it doesn't work, reload the plugin.
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