-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[html] VSCode doesn't automatically close HTML tags #2246
Comments
any update on it? |
@cindoum Sorry, no, we currently have no plans adding this. |
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 |
It is so essential that it should be part of the HTML language service. |
Duplicate of #502 (?) |
+1 This makes coding faster. |
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. |
You may want to use Auto Close Tag extension, and it supports for both Visual Studio mode and Sublime Text mode. |
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. |
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:
Thanks @formulahendry for leading the way with his extension. Note that the auto-close extension has more features, in particular, configurable support for more languages. |
Thanks @aeschli , that's cool! I will take a look. |
Does it work also with JSX/TSX? |
@rosieks No, this is only for html, handlebars and razor files. |
Thx, @aeschli , you rock! |
@formulahendry , how is @aeschli 's solution different from the Auto Close Tag extension? |
@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. |
in html file-type
vscode version 0.10.6
My User Settings config says:
"editor.autoClosingBrackets": true,
but it still doesn't work.
For example, when you type in "<script" the IntelliSense suggestions pops up and you press enter on "script" it doesn't close the tag like this:
but it stays like this:
The text was updated successfully, but these errors were encountered: