Skip to main content

Note

ifIf you are talking about prettier for tabSizetabSize, go to the Method 2 of this answer.

Method 1 (VS Code Way)

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 
{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

Method 2 (If using prettier)

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc

Note

if you are talking about prettier for tabSize, go to the Method 2 of this answer

Method 1 (VS Code Way)

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

Method 2 (If using prettier)

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc

Note

If you are talking about prettier for tabSize, go to the Method 2 of this answer.

Method 1 (VS Code Way)

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

Method 2 (If using prettier)

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc
added 5 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99

Note

if you are talking about prettier for tabSize, go to the sectionMethod 2 of this answer

SectionMethod 1: VS (VS Code Way)

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here


SectionMethod 2: If (If using prettier)

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc

Note

if you are talking about prettier for tabSize, go to the section 2 of this answer

Section 1: VS Code Way

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here


Section 2: If using prettier

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc

Note

if you are talking about prettier for tabSize, go to the Method 2 of this answer

Method 1 (VS Code Way)

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

Method 2 (If using prettier)

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc
deleted 10 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99

Note

if you are talking about prettier for tabSize, go to the section 2 of this answer


 

Section 1: VS Code Way

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

 

 Enter image description here


Section2Section 2: If using prettier

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc

Note

if you are talking about prettier for tabSize, go to the section 2 of this answer


 

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

 

 Enter image description here


Section2: If using prettier

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc

Note

if you are talking about prettier for tabSize, go to the section 2 of this answer

Section 1: VS Code Way

Well, if you like the developer way, Visual Studio Code allows you to specify the different file types for the tabSize. Here is the example of my settings.json with default four spaces and JavaScript/JSON two spaces:

{ // I want my default to be 4, but JavaScript/JSON to be 2 "editor.tabSize": 4, "[javascript]": { "editor.tabSize": 2 }, "[json]": { "editor.tabSize": 2 }, // This one forces the tab to be **space** "editor.insertSpaces": true } 

PS: Well, if you do not know how to open this file (specially in a new version of Visual Studio Code), you can:

  1. Left-bottom gear →
  2. Settings → top right Open Settings

Enter image description here


Section 2: If using prettier

If you are using prettier, things may be different again, prettier has 2 level of setting for this:

  1. User level, which you can click the extension and click setting find the keyword tabWidth
  2. Project level, which you can add/update from the root project level in file .prettierrc
Layout and spelling
Source Link
Liam
  • 30k
  • 28
  • 143
  • 206
Loading
added 461 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
Active reading [<https://www.youtube.com/watch?v=1Dax90QyXgI&t=19m05s> <https://en.wikipedia.org/wiki/Visual_Studio_Code>]. Made compliant with the Jon Skeet Decree - <https://twitter.com/PeterMortensen/status/976400000942034944>. Used more standard formatting.
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
added 87 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
Open Settings VScode
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
added 98 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
added 8 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
deleted 5 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
Active reading [<https://en.wikipedia.org/wiki/Visual_Studio_Code>].
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134
Loading
added 27 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
deleted 6 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
Code highlighting
Source Link
Gama11
  • 34.6k
  • 9
  • 92
  • 107
Loading
added 7 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
added 47 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
added 4 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
added 83 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
deleted 60 characters in body
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading
Source Link
Xin
  • 37.1k
  • 18
  • 89
  • 99
Loading