Visual Studio Code disable auto closing tags - visual-studio-code

I'm trying to prevent auto closing tags, but the following setting doesn't seem to work:
{
"html.autoClosingTags": false,
}
What else must be done to make auto-closing tags go away?

Just in case anyone looking at this is finding that HTML tags are still being automatically closed inside JSX files. The setting you need is:
{
"javascript.autoClosingTags": false,
"typescript.autoClosingTags": false
}

Open Visual Studio Code, go to Preferences -> Settings
Under the User Settings tab, click Text Editor, and search for the setting Auto Closing Tags. Uncheck HTML: Auto Closing Tags
This search results also allow you to disable auto closing for JavaScript and TypeScript, if desired.
Based on Visual Studio Code 1.64.2 for macOS.

For me, the solution was in an extension. I had the Auto Close Tag extension installed (who knows when I though that was a good idea) that was overriding the built in autoclose. Disabling the extension fixed it.
Take a look through your enabled extensions and see if there's any that might be adding this behavior.

The following worked for me:
Go to File > Preference > Setting (Ctrl + ,)
Extension > HTML
And remove tick from the "Auto Closing Tags".
Hope this helps. Cheers :)

Disabling autoclosing for only TypeScript generics
To eliminate autoclosing on TS <generic> tags, but leave it on otherwise, install the Auto Close Tag VSCode extension and add the following lines to your JSON user settings:
{
"auto-close-tag.disableOnLanguage": [
"typescript",
"typescriptreact"
]
}
Further Reading: TypeScript Generics: Adds closing "Tag" to type specifier #17

You might need to delete the comma after "false" - Visual Studio Code doesn't seem to like commas after the last statement in preferences.

Just ran into this problem and I went to preferences -> settings -> extensions -> HTML -> disable autoclosing of HTML tags. Hope this helps!

I just looked this one up myself and noticed there was no verified answer. Those saying you have to go to the HTML portion are absolutely correct, if you don't uncheck that checkbox under HTML: Auto Closing Tags then you will keep getting the closing tags.

Related

How to enable Codesandbox auto complete again?

Well, Codesandbox stopped working properly from one day to another, it doesn't auto complete or make any suggestions while writing code and emmet abbreviation doesn't work either. I went to File -> Preferences -> Settings and enabled JavaScript Autoclosing Tags checkbox on but still not working, any suggestions?
You have to turn Emmet back on - for autocompleting tag and component names. Not sure when, or why, this was removed from the default behavior when it's the default behavior of just about every other editor.

Disable onsave formating for .ejs files in visual studio code

I'm working with ejs files, but in order to reuse some code, I'm using the includes feature. Given that some opening/closing html tags are placed in other files, after I save my changes, something (I don't know if prettier extension or VS code editor) is including the closing tags into my code, causing several problems when I running it.
An other solution is to use a .prettierignore file and put in :
*.ejs
in your settings.json you should add these settings.
just instead of "[css]" type what you want. (the format of the file)
and just please ignore line 2 :) that's not related to this answer.
Edit
as #aegatlin said use this: "[html]".(if "[ejs]" didn't work for you)
I don't use EJS myself, but after playing around with it in VSCode, I noticed that my .ejs files were being treated as HTML files. You can see how your VSCode is interpreting the file by looking in the bottom right corner of the editor. You could search for EJS extensions as well.
You likely have the "Editor: format on save" option enabled. To disable that setting, go to Preferences, and in the search bar type "format on save". Find the setting. Uncheck the box. That should fix the problem.
If, as you mentioned, your closing HTML tags are in other files, then you have invalid HTML and the formatter (both Prettier's and the default one) will autocomplete the closing tag. (I would wager EJS also wouldn't like the lack of closing tags, but since I don't use it I'm not so sure, maybe it's fine.)
Zulhilmi Zainudin has the solution
https://medium.com/#zulhhandyplast/how-to-disable-vs-code-formatonsave-for-specific-file-extensions-c60e8f254243
In vscode setting file, associate ejs extentions files to a « language ». Then you can specify different rules for this that language :
.vscode/settings.json file content :
{
"files.associations": {
"*.ejs": "ejs" // this create the language « ejs » which refers to any .ejs file
},
"[ejs]": { // custom settings for the language « ejs »
"editor.formatOnSave": false
}
}

How to turn on Auto Close Tag and Auto-Find Closing Tag

I've been using Visual Studio Code without trouble for approximately 1 year.
However a few days ago 2 features inexplicably turned off.
1) Auto Close Tag stopped.
When I open a DIV a closing DIV is no longer created.
2) Auto-find the closing tag stopped.
When I select an opening DIV it no longer highlights the closing DIV but instead highlights all DIVs in the entire document.
I believe these 2 features have been standard for some time.
August 2017 (version 1.16)
I checked my preferences by going to,
File > Preferences > Extensions > HTML
Auto Closing Tags
Enable/disable Autoclosing of HTML tags.
The box for Auto Closing Tags was checkmarked.
I'm at a loss. I'm not sure where else to check or which preferences need to be changed to get it back to the way it was.
I found this elsewhere on StackOverflow:
"I had the same problem. After reviewing the answer above, I noticed that VS Code auto-detected a different language than HTML, even though the file I was editing had the ".html" extension. After selecting HTML as the working language, the editor now auto-closes the tags."
and this:
"After I change the environment it be solved!"
install this extension
highlight-matching-tag
and change the settings.json to
some changes in setting, goto file->preferences->setting, you can now see User settings in the right hand side, add the following code
"files.associations": {
// extension name : html
"*.php": "html",
"*.html": "html"
}
"highlight-matching-tag.styles": {
"opening": {
"full": {
"highlight": "rgba(255, 202, 202, 0.9)"
}
}
}
and you are ready to go. Enjoy :)

How to set up vscode to close window for tags in html?

The window in the picture
enter image description here
If you meant to ask us how to set up Visual Studio Code to automatically add closing tags to XML elements such as the element shown in the picture, afaik I don't think the software features this kind of functionality built in. You might have to go the way of using add-ons, such as these two:
Auto Close Tag for Visual Studio Code
Auto Close Tag by Jun
Han
A web search could easily bring up a couple more. Go ahead and give it a try; if it isn't what you want, please edit your question and make it clear to us.
Okay, after some further research, there is an open issue on getting more control over those hover popups see disable hover in editor.
The suggestion is to use the undocumented setting:
"editor.hover": false,
which works after a restart of vscode. You must restart vscode to get it to work. Unfortunately that applies to all files of any kind and
"[html]": {
"editor.hover": false,
}
does not work so you have to use just
"editor.hover": false,
instead.

how to add Intellisense to Visual Studio Code for bootstrap

I'd like to have intellisense for bootstrap specifically but even for the css styles I write in my project. I've got references in a project.json and a bower.json but they do not seem to be making the references available.
You can install HTML CSS Support Extension.
ext install vscode-html-css
This will add Intellisense in your HTML files:
You don't need to configure anything for local files, just close and reopen vscode after installing. For remote css files, you can add the following
"css.styleSheets": [
"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
]
in the settings.json
Here is the common steps (not only for Bootstrap) to enable css IntelliSense in VS Code:
Step 1: Go to https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion
or https://marketplace.visualstudio.com/items?itemName=gencer.html-slim-scss-css-class-completion
(Installation steps are already there)
Step 2: Click Install button that appear on the top of the website (screenshot below)
Step 3: After click, browser will show a pop-up window to access VS Code. Open it with VS Code.
Step 4: Click again the "install" button that appear inside the VS Code.
Step 5: After restarting the software, click the bottom left icon shown in the below image:
Step 6: Press "ctrl+[space]" inside the class quotes, you will get the complete class names from the attached stylesheets.
In the latest version of VS Code the IntelliSense in comments and strings have been disabled by default. Below are the two options to bring back "24/7 IntelliSense" functionality or customize it to your own liking.
First make sure you have installed the HTML CSS Support Extension mentioned by dwonisch above.
Control + ',' to go to settings or click File -> Preferences -> Settings.
Click workspace settings tab and enter the following JSON code:
{
"editor.quickSuggestions": {
"comments": false, // <- no 24x7 IntelliSense in comments
"strings": true, // but in strings and the other parts of source files
"other": true
}
}
The other option is to hit ctrl + space within the CSS quotes to activate the intelliSense. Example:
<div class="(ctrl+space)"> </div>
just add this 2 packeges and you are done.. !!!
Just install this extension in VS Code.
IntelliSense for CSS class names in HTML
Unfortunately, this feature is not currently available in VS Code. However, it has been added as a feature request for upcoming updates. You can track the issue on Github.
Open Visual Studio Code.
Use CTRL+, to get to the Workspace Settings
At your Right side window you will see something like this:
Another words paste this URL
{
"folders": [
{
"path": "D:\\Visual Studio\\AndreyCourse\\the-complete-web-developer-in-2018\\DocumentObjectModel"
}
],
"settings": {
"css.remoteStyleSheets": [
"https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css"
]
}
}
Enjoy The Bootstrap Intellisense :-)
For React use install this extension in VS Code
1: install IntelliSense for CSS class names in HTML
but this extension works on class property as default so update the settings to work on className.
2: create a extensions.json file in .vscode folder and add the below object
{
"recommendations": [
"Zignd.html-css-class-completion",
"html-css-class-completion.JavaScriptLanguages"
]
}
"Zignd.html-css-class-completion" for class property
"html-css-class-completion.JavaScriptLanguages" for className property
I am using Latest version of VS Code 2022 1.72.2. I have installed below Extension all the HTML, CSS and Bootstrap intelligence working fine.
IntelliSense for CSS class names in HTML
Turn comments on if required in setting by pressing ctrl+,
"editor.quickSuggestions": {
"comments": true,