萧逸清
萧逸清

Reputation: 375

how to set json with comment in vscode?

I often use Vs code to open json files. sometimes there're some comments in my json files. in this case,there will be a lot of warnings.

So I click below button to change the format to "json with comment (jsonc)"

enter image description here enter image description here

but when I open a JSON file next time, it will by default switch to JSON format (without comment)

How can I make 'jsonc' the default format of json file? so that I do not need to change it every time.

Thanks

Upvotes: 17

Views: 16412

Answers (1)

oreid
oreid

Reputation: 1507

You can set a file association between json files and jsonc language formatting.

In VS Code open Settings in JSON view by using the Command Pallet (Cmd + Shift + P) and enter Preferences: Open Settings (JSON). Next, add the following (or append to the existing files.associations object if it already exists):

"files.associations": {
    "*.json": "jsonc"
}

Upvotes: 28

Related Questions