James Ko
James Ko

Reputation: 34489

Is it possible to change the default VSCode formatting settings for a particular language?

I want to have VSCode indent C files by 2 spaces by default. Is it possible to do this? Thanks.

Upvotes: 4

Views: 8067

Answers (2)

Mark
Mark

Reputation: 180641

Adding to @Batman's answer after you amended your question via a comment (since this is too long to put into a comment): look into "configure language-specific settings..." in your command palette. It'll create

"[c]": {}

at the bottom of your settings.json so you can add anything there like:

"[c]": {

  "editor.tabSize": 2,
  "editor.insertSpaces": true,
  "editor.detectIndentation": false
}

and that will only affect C files.

Upvotes: 4

Mahesh G
Mahesh G

Reputation: 1276

File > Preferences > Settings

Below Setting worked for me

"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": false

Code In Visual Studio Code

Upvotes: 1

Related Questions