Enable Emmet for .tsx files on VSC
Asked Answered
T

3

18

I'm using Visual Studio Code. How can I enable emmet on .tsx files?

I'd like a simple

.foo + tab

to be expanded to

<div className="Foo"></div>

However, nothing I tried seemed to trigger emmet with the desired behavior above.

Here's my VSC settings:

  "emmet.triggerExpansionOnTab": true,
  "emmet.includeLanguages": {
        "javascript": "javascriptreact",
        "typescript": "typescriptreact",
    },
Telugu answered 9/4, 2018 at 17:22 Comment(1)
Hi, the settings you have described in your question works fine for .js and .tsx file with JSX support. One reason it might not be working for you is, "emmet.showExpandedAbbreviation": "inMarkupAndStylesheetFilesOnly" which should ideally be "emmet.showExpandedAbbreviation": "always" as was in my case.Globeflower
S
34

I set this in my VS Code user settings and it works as desired for .tsx files:

"emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "typescript": "typescriptreact"
}
Spinescent answered 12/8, 2018 at 13:45 Comment(0)
T
9
"emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "typescript": "javascriptreact"
},

this is my setting, it can work well

Thoughtful answered 26/6, 2018 at 6:45 Comment(0)
P
3

Open settings. here's a quick shortcut: for windows use Ctrl + , while on mac hit Command + ,

look for the key includeLanguages. Enable Emmet abbreviations in languages that are not supported by default. here's an example:

"emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "typescript": "javascriptreact"
},

Adjust "emmet.showExpandedAbbreviation" based on your needs (either use Always or inMarkupAndStylesheetFilesOnly)

In settings, it should be like this

"emmet.showExpandedAbbreviation": "Always"

and Here's a screenshot that might be helpful

Emmet settings

Pebrook answered 6/6, 2022 at 18:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.