Search code examples
visual-studio-codeprettier

how to set prettier unique for different languages in vscode settings.json file?


I am using prettier extension in vscode to format both html and md files, it is beautiful to set tabwidth = 4 in html files, but ugly in md. I set prettier.tabWidth in vscode settings.json

"prettier.tabWidth": 4

But this setting will take effect for all languages. Is there a method that can set the prettier in settings.json and only sets the indentation of HTML files without affecting the indentation of MD files?


Solution

  • Unfortunately, prettier doesn't work that way in settings.json or even with a global rc file. At this point I have a directory with presets for prettier which I copy/paste to my package.json per project within vscode.

    package.json(per project🤡):
    
    "prettier": {
      "tabWidth": 2,
      "useTabs": false,
      "singleQuote": true
    }