StrangeMann
StrangeMann

Reputation: 251

How to set different default formatters in VSCode settings?

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

Answers (2)

Izebeafe
Izebeafe

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.

Reference image for more clarificarion

Upvotes: 23

Jayzor
Jayzor

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

Related Questions