Reputation: 251
Is it possible to set different default formatters for different languages in VSCode? I want VSCode to autodetect the language used in current file and use the appropriate editor. How can I achieve this?
Upvotes: 14
Views: 12164
Reputation: 520
You can press Ctrl
+ ,
keys to access the settings in VS Code, and then type in @lang:language-name
Default Formatter (e.g @lang:html Default Formatter) or just scroll down to where it says Editor: Default Formatter and then choose the formatter for that language.
Upvotes: 23
Reputation: 493
You can edit your settings.json file and type these depending on which language you want to use. In my case I have a formatter for HTML and a separate one for Javascript:
{
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "remimarsal.prettier-now"
}
}
Upvotes: 7