how to add Intellisense to Visual Studio Code for bootstrap - visual-studio-code

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,

Related

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 :)

Beautify on save in VS code?

I just installed a beautify extension for vs code
I want to have my code beautified whenever I save a file, but can't figure out how to configure it that way.
It says
Beautify on save will be enabled when "editor.formatOnSave" is true.
But i have no idea where to put it exactly as I cannot find the default option in any of the files.
I'm trying to switch to VS code and figure things out.
For Windows click on 'File' -> Preferences -> Settings. Then search for editor.formatOnSave, and put "true" instead of "false"
For Mac click on 'Code' (top left of screen, to the left of 'File', 'Edit', and 'View') -> Preferences -> Settings -> enter the term 'editor.formatOnSave' in the search settings box at the top of the page. Click on the tick to mark it as true.
Go to file--> preferences --> settings
In search type formatter and in default formatter select : prettier code formatter as shown in below screenshot.
I visited this question because my beautify was not working in VS code
And Adding the above mentioned setting fixed my issue but if you want your beautify to solve linting issue as well then you gonna have to added the below setting along with the above like this : (Hope this helps anyone)
{
"editor.formatOnSave": true,
"tslint.autoFixOnSave": true
}
My setup for Javascript relies on ESlint and Prettifier.
I got the autoformat/autofix configuring:
"editor.codeActionsOnSaveTimeout": 2000,
"editor.codeActionsOnSave": {
"source.fixAll": true
}
In addition to the other answers, it may be that you have to override or replace your defaultFormatter settings in your settings.json file if you use other formatters.
When I installed Prettier, for example, it installed as the default formatter for several different languages, including HTML, which is broken for Django HTML templates.
Open settings.json file (SO guide if you get stuck
In my case, prettier had installed as default as follows, but you might have another formatter instead:
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
If you remove esbenp.prettier-vscode and start typing a few characters, VScode will highlight in red you have entered an invalid formatter and suggest valid values. Once you have installed Beautify, you can replace this entry with: HookyQR.beautify
And make sure to follow the other answers on this post.

Visual Studio Code disable auto closing tags

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.

How to make VS Code change language to JavaScript React when open a JSX file

Currently, when I open a .jsx file the default language is plain JavaScript. Is there a way to set the editor to change the language based on the file extension?
Ideally, I can put this setting in both my local setting config file OR the workspace specific config file.
The version I am using is Version 1.15.0-insider (1.15.0-insider).
Press cntrl + , and add this to user settings JSON file:
"files.associations": {
"*.js": "javascriptreact"
}
like this:
Within VS Code, in the bottom right of the window you will see a smiley face - to the left of that is the language the currently visible file is associated with (e.g. JavaScript). Ensure your currently opened file is a .jsx file.
Clicking this will reveal a menu at the top. Click the Configure File Association for '.jsx'..., and then choose "JavaScript React".
The setting goes to config file should be something like below,
"files.associations": {
"*.jsx": "javascriptreact"
}
why not like this ?
Open your setting.json in vscode and add or edit files.associations like below:
"files.associations": {
"**/src/**/*.js": "javascriptreact",
"**/src/**/*.jsx": "javascriptreact"
}
I wounder to know why no one shared this on internet (at least I haven't found).
This code will auto detect your react files since we wrote path for it, it will find src folder of your react app and detect all of the .js, .jsx files as react and you can still have your .js files out of src folder like public or anywhere else you like.
I have to let you know, in your non react project all of .js, .jsx files inside of src folder gonna detect as react file as well because we wrote the setting like this and I don't know any better way.
Instead of the config file, I do click on the extensions in the bottom right of the window. Then click on configure File Association for '.jsx' and he asked me to select a language and I selected Javascript React. and now all the files are Javascript React with a little react icon
press ctrl+shift+P and then go to user settings, after that, Search for file.associations
and then click add item. In the key input-field enter *.js and in the value input-field enter javascriptreact
Open that JavaScript file. On the bottom left You can see the language"JavaScript".
Click on it and select "JavaScript React".
Now Done:)
You can add this to your File: association under settings in vscode:-
key - *.js value - javascriptreact

How to activate Markdown user snippets in Visual Studio Code?

User Snippets are an awesome feature of Code, however, I can't get them to work for Markdown files. A markdown.json file exists and is editable, but I can't get snippets defined in that file to activate (using Tab like for other languages). Is there a different activation method for these snippets or are they just not supported yet?
EDIT: Here's the contents of the markdown.json file just in case I'm doing something wrong there.
{
"Markdown comment": {
"prefix": "comment",
"body": [
"<!--- \n --->"
],
"description": "A Markdown comment"
}
}
Open the editor
Go to File -> Preferences -> User Snippets
Select Markdown. The file C:\Users\YOU\AppData\Roaming\Code\User\snippets\markdown.json will be opened
Paste your snippet into the file and save it
From now on you can use the snippet in all .md files.
In case the snippet suggestion doesn't popup when you type "comment" then you should type CTRL + Space to force it.
https://github.com/Microsoft/vscode/issues/26108
in case you mean no popup quick suggestion, the link is the cure.
"editor.quickSuggestions": true
add this to user setting then you should be able to see the popup snippet suggestions
https://github.com/Microsoft/vscode/issues/1617#issuecomment-166999086
Full extensions get auto (7x24) completion by default (e.g. latex, cake), some built-in extensions like Markdown do not.
You have to type CTRL + Space to force it.