Recently switched from Sublime Text 3 to VS Code. Overall pleased with the switch except for this one little thing that's just annoying enough to be a dealbreaker if there's no solution. In ST3 if I type, say, a <div>
, it doesn't automatically drop in a </div>
, which is nice because I'm often pasting it in and don't want it closed right there.
What ST3 DOES do, however, is complete the tag the moment I type </
. It autofills div>
the moment I type the forward slash. This is the behavior I want from VS Code. I can't find any mention of this anywhere which is completely baffling. I know how to autoclose tags, but that's no good becasue then I have to manually close them. I want VS Code, like ST3, to autocomplete the tag for me, just not immediately.
First, go to the Settings and search for "HTML: Auto Closing Tags" and uncheck the setting that is checked by default.
File > Preferences > Keymaps, Search 'Auto close' and click on install. If it doesn't work, reload the plugin.
A self-closing tag is an element of HTML code that has evolved in the language. Typically, the self-closing tag makes use of a “/” character in order to effectively close out a beginning tag enclosed in sideways carets.
Go to File > Preferences > Settings, search for html.autoClosingTags
and set it to false
.
This will make it so when you type <div>
, it won't insert </div>
automatically, but if you start typing </
, it won't close the tag automatically. You can press ENTER to make it autocomplete for you.
Or you can leave this option enabled and when you type <div>
and it autocompletes, you can just press CTRL + Z.
More information on this behavior here.
Add this to settings.json to make it work like Sublime Text:
"html.autoClosingTags": false,
"auto-close-tag.SublimeText3Mode": true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With