Visual Studio Code Emmet not working
Asked Answered
H

22

50

I am using VisualStudioCode 1.20.1 Version. Emmet is inbuilt according to VSC website.But when i am trying on VSC IDE and using anchor tag and referring to class dropdown-toggle the class is not auto suggested or recognized by vsc.

Habitation answered 20/2, 2018 at 15:37 Comment(0)
T
117

In your vscode user setting, add

"emmet.includeLanguages": { "javascript": "html" }

That way you can use emmmet in your js files.

Tragacanth answered 18/7, 2018 at 4:20 Comment(4)
Thanks, this fixed it for me.Sakti
This [link] (code.visualstudio.com/docs/editor/emmet#_emmet-configuration) shows the configuration to enable mapping between the languages supported by Emmet and language of our choice. However I was not able to get suggestions from Emmet, so I had to add a duplicate entry for 'javascript' as suggested above by @tienl to get it working.Oloroso
4 years later, this still fixed it for me.Ivey
6 years later, this still fixed it for me. –Estrella
G
65

in vs code user setting add these

"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "vue-html": "html",
    "razor": "html",
    "plaintext": "jade"
}
Glaydsglaze answered 14/12, 2018 at 4:22 Comment(2)
This code "emmet.triggerExpansionOnTab": true works for me. When you accidentally type something (e.g. pa instead of p for paragraph tag) and you delete the letter "a" and press tab, without this code emmet won't work.Astylar
hey , its not working inside .html file script tag , can you help with this , with above code I'm getting emmet autosuggestions in js , vue and HTML file but not in between of strip tag <script> its not working inside this </script>Alforja
P
34

This following worked for me:

  1. Open Command Palette (Ctrl + Shift + P)

  2. Open Settings (JSON)

  3. Add to the end:

    "emmet.showSuggestionsAsSnippets": true,
    "files.associations": {
        "*html": "html", 
        "*njk": "html"
    },
    
Ppi answered 29/6, 2020 at 8:47 Comment(1)
thanks. this has worked to add mustache templates as htmlHydropathy
P
17

I'd like to add to the others posting about emmet.includeLanguages, you can also add "vue": "html", so like:

"emmet.includeLanguages": { 
        "vue-html": "html",
        "vue": "html",
        "javascript": "html"
    }
Piedadpiedmont answered 15/7, 2019 at 17:37 Comment(1)
this is what did it for me, "vue-html" on its own was not enough, added the "vue" entry as well and it worked.Shortcake
B
14

Emmet does not work on js file by default. To solve that problem you have to enable emmet abbreviation in the vscode's settings. First, open settings.json from any directory:

vim ~/.config/Code/User/settings.json

To be more specific, on windows, you need to go to File > Preferences > Settings > Type in "Launch" > click on "Edit in settings.json"

Now you have to declare in settings.json that you will use emmet at js files: (Its very simple just copy and paste into code setting file the code highligted)

{
    /*here are your existing settings*/
    /*THE CODE BELOW*/
    "emmet.triggerExpansionOnTab": true,
    "emmet.includeLanguages": {
        "javascript": "javascriptreact",
        "vue-html": "html",
        "razor": "html",
        "plaintext": "jade"
    }
     /*^^^^THE CODE ABOVE^^^^*/
}

Now just save it. Not necessary restart vscode.

For more details see that post at vscode official webite.

Brimstone answered 11/8, 2019 at 22:56 Comment(0)
N
9

The issue is that you need to include the language in your settings file.

With newer versions of VSCode, you can open up settings by selecting Code > Preferences > Settings and then search for "Emmet: Include Languages" and simply add your language there.

I just did this to get emmet working on my react code. I just did this to get emmet working on my react code.

Notum answered 1/9, 2021 at 10:39 Comment(0)
A
8

Check the file extension icon, does it show up as html5 or dj (which stands for django)?

enter image description here

If it shows as dj, then you have the Django VSCode extension. You can either:

  • Remove the Django extension
  • Add "django-html": "html" to emmet.includeLanguages (as per this issue), so mine now looks like this:
  "emmet.includeLanguages": {
    "vue-html": "html",
    "javascript": "javascriptreact",
    "django-html": "html",
  },
Acidimeter answered 12/4, 2021 at 4:56 Comment(1)
Thank you! : D Added the django-html": "html, without removing the django extension or anything else and it works! Thanks!Peculiar
F
6

Something I ran into that was driving me crazy trying to figure out was that the setting "emmet.showExpandedAbbreviation" will affect emmet working in your javascript files too.

To solve, remove it from your settings.json or set it to: "emmet.showExpandedAbbreviation": "always"

Fecteau answered 25/4, 2020 at 21:23 Comment(1)
Dear God ... this was basically me too. That setting was just not in my settings.json even though it appeared to be when I was using the VSCode UI to toggle my settings. So - once I opened the settings.json I saw it was missing, added it, restarted ... and FINALLY I get emmet intellisense stuff! Thank you so much.Niel
F
2

find setting.json file and add this code and save it and if you don't know how to do it then watch this video https://www.youtube.com/watch?v=AUuP_hriEc4`

"files.associations": {"*html":"html"}, "emmet.triggerExpansionOnTab": true

`

Flush answered 10/7, 2022 at 17:46 Comment(0)
A
1

With aspnetcorerazor and razor language selection add the below code in your setting.json file:

"emmet.includeLanguages": { "aspnetcorerazor" : "html", "razor" : "html" }
Adore answered 1/4, 2020 at 14:10 Comment(0)
S
1

This happened to me in HTML files because another extension (for Django, a Python web framework) was overriding .HTML file types without a way to turn it off. I removed the extension, restarted VSCode, and now it's working again.

Solarize answered 18/11, 2020 at 22:28 Comment(2)
simply adding "django-html": "html" to the user settings in VSCode -as @Ben Butterworth suggested- worked for mePeculiar
removing a extension is not a solution because of extensions useful in many ways.Callboy
U
1

In your setting.json file add this line "emmet.triggerExpansionOnTab": true,. Then ! and tab will do the work.

Unalloyed answered 16/10, 2021 at 7:7 Comment(0)
I
1

Go to VS Code settings -> Search Emmet -> In section Emmet:Include Languages, add {item, value}

{javascript :javascriptreact}

picture here

Indicia answered 11/7, 2022 at 4:44 Comment(0)
T
0

Tried all above , didn't work.

Updated my VScode by reinstalling it from here and everything works like a charm now.

Twylatwyman answered 11/4, 2020 at 9:11 Comment(2)
You may have had the same issue I did https://mcmap.net/q/346854/-visual-studio-code-emmet-not-workingFecteau
I tried everything , including your solution as well.Twylatwyman
S
0

Simply uninstall the extension related to HTML or CSS And it work for me nicely

Satterfield answered 2/11, 2020 at 7:49 Comment(1)
what if we want to use that extension? please avoid writing a solution if it is unnecessaryCallboy
D
0

"editor.defaultFormatter": "VisualStudioExptTeam.vscodeintellicode"

Delmore answered 30/12, 2020 at 0:55 Comment(0)
S
0

for me emmet auto-fill stopped to work on single html page ; turnout it was bcz i used "<" twice not on a tag ( like withen the text) , remove them or but \ before them or use them inside (prism cdn is recomended then) will solve the issue

Skeleton answered 24/6, 2022 at 15:44 Comment(0)
D
0

I ran into this issue today and realized that the following setting wasn't checked. When I checked the box, I went back to a test HTML file and used "!" to bring up the boilerplate, and this time it worked.

"Emmet: Use inline Completions"

Date answered 10/7, 2022 at 7:20 Comment(0)
G
0

Step 1: Start your VS Code. Click on the Settings or press Ctrl+, to open the VS Code Settings.

Step 2: Click on the Extensions tab on the left side of the settings. Click on HTML.

Step 3: Click on the Edit in settings:json hyperlink to edit the settings in JSON format.

Step 4: Inside the curly braces, enter the following code under the already written JSON code:

“emmet.triggerExpansionOnTab”:true,
“files.associations”: {“*html”:“html”},
“emmet.useInlineCompletions”:true

Step 5: Save the file. Now if you try to apply Emmet in your code, it will work smoothly!!

Gnarl answered 15/7, 2022 at 14:23 Comment(0)
D
0
  1. You have to uninstall your VS code and Node.js by going into control panel → program & features.

  2. After the uninstall is copmlete, go to C:\Users\your_user_name_folder.

  3. After reaching there, delete the .vscode folder.

  4. Go to AppData\Roaming\Code (delete this Code folder).

  5. Go to C:\Users\<your_user>\AppData\Local\Programs and delete the Microsoft VS code folder.

  6. Now go to C:\Users\rajat\AppData\Local and delete the npm_cache folder.

  7. Now reinstall Node.js and VSCode.

Disquisition answered 30/1, 2023 at 12:3 Comment(0)
C
0

if the problem is occurring due to any Django extension then simply adding "django-html":"html" in "Emmet: Include Languages" in the settings will solve the problem. Like this

Callboy answered 18/3, 2023 at 5:0 Comment(0)
H
0

This code also worked

{
    "cmake.showOptionsMovedNotification": false,
    "emmet.preferences": {
        
        "emmet.includeLanguages": {
            "javascript": "javascriptreact",
            "typescript": "javascriptreact",
            "html": "html",
            "css": "css",
            "php": "php",
            "python": "html",
            "java": "html"
        },
        "emmet.triggerExpansionOnTab": true,
        "emmet.showSuggestionsAsSnippets": true
    },
    "emmet.syntaxProfiles": {
        "javascript": "jsx",
        "typescript": "jsx"
    },
    "prettier.disableLanguages": [
        "html"
    ],
    "html.format.enable": true,
    "editor.wordWrap": "off",
    "html.format.indentInnerHtml": true,
    "files.associations": {
        "*.html": "html",
        "*.njk": "html"
    },
    "vscode-edge-devtools.webhint": false
}
Hangnail answered 2/5 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.