Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code - Turn off auto close tags, but leave on autocomplete

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.

like image 408
Ari K Avatar asked Mar 20 '18 18:03

Ari K


People also ask

How do I stop VS Code from auto closing tags?

First, go to the Settings and search for "HTML: Auto Closing Tags" and uncheck the setting that is checked by default.

How do you autocomplete tags in VS Code?

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

What is auto close tag?

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.


2 Answers

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.

like image 96
Phiter Avatar answered Oct 21 '22 07:10

Phiter


Add this to settings.json to make it work like Sublime Text:

"html.autoClosingTags": false,
"auto-close-tag.SublimeText3Mode": true
like image 3
artist learning to code Avatar answered Oct 21 '22 06:10

artist learning to code