简体   繁体   中英

How to specify different formatting for different files in VS code/Prettier

Does anyone know if it's possible to have VS Code auto format different file extensions differently?

For example I want:

JS - 4 spaces, CSS - 2 spaces and HTML - 2 spaces

You can use Language Specific Settings . In your settings.json do like so:

{
  "[javascript]": {
    "editor.tabSize": 4
  },
  "[css]": {
    "editor.tabSize": 2
  },
  "[html]": {
    "editor.tabSize": 2
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM