I've gone through formatting settings and stack overflow posts, I've toggled with a bunch of different settings and can't seem to find an answer to this. Nothing in settings.json
seems to matter, maybe it's being overwritten somehow?
My tab spacing is set at 2 spaces and every time I restart my computer, something seems to happen to VS Code where saving a file adds a ton of weird spacing rules and tabs to 4 spaces, as you can see in the gif below that make my code terrible.
I don't want to go back to Atom or Sublime but the way VS Code is working for me right now, I can't use it in a professional context. Would love some help getting this figured out.
Thanks!
(image below is a gif, click it to see the style change on save)
Edit: installed packages in VS Code:
The easiest way to turn on Auto Save is with the File > Auto Save toggle that turns on and off save after a delay. For more control over Auto Save , open User or Workspace settings and find the associated settings: files.autoSave : Can have the values: off - to disable auto save.
Click the (...) button and then select Undo Last Commit to undo the previous commit. The changes are added to the Staged Changes section.
This comment turns out to have the answer. It happens when you have two settings that shouldn't conflict but do for some reason
"editor.formatOnSave": false,
"javascript.format.enable": false
The solution was to uninstall vscode-JS-CSS-HTML-formatter
which you can do by searching for the author, lonefy
, in your packages.
Its probably Prettier that is doing this.
In your settings.json
add these two lines:
"editor.formatOnSave": false,
"prettier.disableLanguages": [
"jsx",
"js"
],
Or just uninstall prettier
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With