Turn off auto formatting for json files in Visual Studio Code
Visual Studio-CodeVisual Studio-Code Problem Overview
I have checked my preference multiple times and ensured that all options related to format-on-save are set to false. And yet everytime I save a .json file I see my file getting formatted.
Visual Studio-Code Solutions
Solution 1 - Visual Studio-Code
EDIT: Uninstall the extension, there are many other far better maintained formatters out there (e.g. Beautify)
OK, check if you have installed this extension: "JS-CSS-HTML formatter".
Now if you have, press CTRL+SHIFT+P, type "Formatter" and you should see an option that says Formatter Config.
After selecting that option, a file named formatter.json opens and all you do is edit the property (named onSave) from having true to being false.
Restart vs code and voilĂ !! It stopped auto formatting. (yay!!!!)
Solution 2 - Visual Studio-Code
In Visual Studio Code, in order to stop autoformatting only for your json files add the following in settings.json
file by opening User Settings - Preferences.
{
"[json]": {
"editor.formatOnSave": false
}
}
Solution 3 - Visual Studio-Code
I am using the below version of VS Code
Version: 1.28.2 (user setup)
Commit: 7f3ce96ff4729c91352ae6def877e59c561f4850
Date: 2018-10-17T00:23:51.859Z
Electron: 2.0.9
Chrome: 61.0.3163.100
Node.js: 8.9.3
V8: 6.1.534.41
Architecture: x64
And turned it off with the following steps:
CTRL+SHIFT+P
- Type
Settings
- Select
Preferences: Open User Settings
Now follow these image instructions:
- Select Save All
- Restart VS Code
Solution 4 - Visual Studio-Code
In VS Code by default Save without Formatting is done by -
on Windows :
STEP 1 : Press CTRL + K then
STEP 2 : Press CTRL + Shift + S
on MAC :
STEP 1 : Press CMD + K then
STEP 2 : Press S
Solution 5 - Visual Studio-Code
look for Settings.json into "project/.vscode/settings.json"
{
"editor.formatOnSave": false
}
Solution 6 - Visual Studio-Code
Worth to note
I like the json formatting that is enabled by default but only wanted to disable it when editing certain files (i.e. I didn't want some massive json files expanded after formatting).
To exclude those certain files from auto formatting, I made my changes and saved without formatting.
Go into your vs code keyboard shortcuts and see what Save without formatting
is set to. In my case (mac user) it was CMD+K
followed by S
. If it's not set, create your own custom shortcut.
Solution 7 - Visual Studio-Code
go to file -> preferences -> settings -> search for Editor: Auto Indent and select none from drop down
also make this change in setting.json "editor.formatOnSave": false,
yah this will work...
Solution 8 - Visual Studio-Code
In addition to answers here, there are settings other than "editor.formatOnSave"
that might be having a similar effect, which you might also want to disable - for example, I had enabled the following in my User Preferences (settings.json):
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
Solution 9 - Visual Studio-Code
Solutions All In One
solution 1
> config your settings.json
file which in the .vscode
folder, if not exists, just create one in the project root level directory.
1.1 disabled format on save for all files
{
"eslint.autoFixOnSave": false,
"editor.formatOnSave": false
}
1.2 only disabled format on save for .json
file
{
"[json]": {
"editor.formatOnSave": false
}
}
solution 2
> just using the VS Code GUI
To open your user and workspace settings, use the following VS Code menu command:
On Windows/Linux: File > Preferences > Settings
On macOS: Code > Preferences > Settings
2.1 open workspace settings
> Command + Shift + P / Win + Shift + P
2.2 search the keyword (like, json
) and set your config as you want
refs
Solution 10 - Visual Studio-Code
my format was set to CMD k + s by default for VS Code to save without formatting. you could try that out
Solution 11 - Visual Studio-Code
Solution 12 - Visual Studio-Code
If it's for lonefy.vscode-js-css-html-formatter-0.2.3\out\src\formatter.json,
try applying:
{
"onSave": false,
"javascript": {...
...
}