You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[html] VSCode doesn't automatically close HTML tags #2246
Dominic Lapointe (@cindoum) Sorry, no, we currently have no plans adding this.
I recommend you using the emmet expansion
enter script, press tab. This expand to <script></script>
You can use the "Auto Close Tag" extension to replace this behaviour. IMO this is better so that VSCode can stay light and people can "enable" features with the extension of choice.
Perhaps this is better as a separate feature request, but it would be useful to integrate auto tag renaming. It's currently available as a popular extension. Thanks.
Reacted by Alfonso Andrés López Molina, globaltommy, Jan Mikula (Miky) and Jun Han
autoClosingPairs - Defines the open and close symbols for the auto-close functionality. When an open symbol is entered, the editor will insert the close symbol automatically. Auto closing pairs optionally take a notIn parameter to deactivate a pair inside strings or comments.
Feature makes it slightly annoying to add HTML to existing tags as it prefers to close the parent tag, instead of creating a new opening tag (I'll have to untrain hitting enter when writing HTML). Esp common occurence with div soup.
I added auto-close to the built-in HTML language support:
typing the > of <sometag> will add the closing tag </sometag>.
typing / of </ will also close the tag.
this behaviour is enabled by default and can be turned off with setting html.autoClosingTags
Thanks Jun Han (@formulahendry) for leading the way with his extension. Note that the auto-close extension has more features, in particular, configurable support for more languages.
Jun, if you can add a check for the new setting that would be great, so the auto-close extension can co-exist with the new support.
Martin Aeschlimann (@aeschli) 's solution is leveraging the VSCode built-in HTML extension. It could distinguish HTML and embedded languages well. So when you write embedded languages inside HTML, there will not be improper auto-close if you write generic like formulahendry/vscode-auto-close-tag#17. While the limitation is that it only works on html, handlebars and razor files.
For Auto Close Tag extension, it is based on regular expression. So it works for any languages, while the limitation is that it could not distinguish HTML and embedded languages.
Activity
[-]VSCode doesn't automatically close HTML tags[/-][+][html] VSCode doesn't automatically close HTML tags[/+]cindoum commentedon Jun 17, 2016
any update on it?
aeschli commentedon Jun 17, 2016
Dominic Lapointe (@cindoum) Sorry, no, we currently have no plans adding this.
I recommend you using the emmet expansion
enter
script, press tab. This expand to<script></script>mahomedh commentedon Jul 14, 2016
You can use the "Auto Close Tag" extension to replace this behaviour. IMO this is better so that VSCode can stay light and people can "enable" features with the extension of choice.
https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-close-tag
Peter-Juhasz commentedon Aug 7, 2016
It is so essential that it should be part of the HTML language service.
glen-84 commentedon Sep 10, 2016
Duplicate of #502 (?)
aeschli commentedon Sep 12, 2016
Yes, #502 is the same. I'll close #502 as dup.
josemi-ca commentedon Dec 18, 2016
+1 This makes coding faster.
richeklein commentedon Mar 21, 2017
Perhaps this is better as a separate feature request, but it would be useful to integrate auto tag renaming. It's currently available as a popular extension. Thanks.
1 remaining item
doivosevic commentedon May 1, 2017
Can't you use the https://code.visualstudio.com/docs/extensionAPI/extension-points#_contributeslanguages ?
autoClosingPairs - Defines the open and close symbols for the auto-close functionality. When an open symbol is entered, the editor will insert the close symbol automatically. Auto closing pairs optionally take a notIn parameter to deactivate a pair inside strings or comments.
stofte commentedon May 17, 2017
Feature makes it slightly annoying to add HTML to existing tags as it prefers to close the parent tag, instead of creating a new opening tag (I'll have to untrain hitting enter when writing HTML). Esp common occurence with div soup.
aeschli commentedon Aug 28, 2017
I added auto-close to the built-in HTML language support:
>of<sometag>will add the closing tag</sometag>./of</will also close the tag.html.autoClosingTagsThanks Jun Han (@formulahendry) for leading the way with his extension. Note that the auto-close extension has more features, in particular, configurable support for more languages.
Jun, if you can add a check for the new setting that would be great, so the auto-close extension can co-exist with the new support.
formulahendry commentedon Aug 29, 2017
Thanks Martin Aeschlimann (@aeschli) , that's cool! I will take a look.
rosieks commentedon Sep 2, 2017
Does it work also with JSX/TSX?
aeschli commentedon Sep 4, 2017
Sławomir Rosiek (@rosieks) No, this is only for html, handlebars and razor files.
johnyradio commentedon Sep 5, 2017
Thx, Martin Aeschlimann (@aeschli) , you rock!
johnyradio commentedon Sep 5, 2017
Jun Han (@formulahendry) , how is Martin Aeschlimann (@aeschli) 's solution different from the Auto Close Tag extension?
formulahendry commentedon Sep 5, 2017
johnyradio
Martin Aeschlimann (@aeschli) 's solution is leveraging the VSCode built-in HTML extension. It could distinguish HTML and embedded languages well. So when you write embedded languages inside HTML, there will not be improper auto-close if you write generic like formulahendry/vscode-auto-close-tag#17. While the limitation is that it only works on html, handlebars and razor files.
For Auto Close Tag extension, it is based on regular expression. So it works for any languages, while the limitation is that it could not distinguish HTML and embedded languages.
[html] VSCode doesn't automatically close HTML tags Fixes microsoft#2246