When I hit alt+tab, VS code do auto save, and formats code, how to stop it?

141 Views Asked by At

When I hit alt+tab, VS code do auto save, and formats code, how to stop it?

Whenever I write some code and go to another tab by pressing alt+tab then VS Code auto saves the code and formats it. But I don't want this functionality. How to stop it?

these are all the settings and note: I am not using "files.autoSave": "onWindowChange"

2

There are 2 best solutions below

3
starball On

Pretty sure this could happen if you have the following combo of settings:

"editor.formatOnSave": true,
"files.autoSave": "onWindowChange",

Just tinker with those settings (and the related ones) until you get what you want.

There might also be bugs with the feature, such as was found and fixed in issue ticket #206475, which looks like it might be the same issue you're having: when files.autoSave is set to afterDelay and editor.formatOnSave is set to true,

0
hb20007 On

There was a bug in VS Code which caused AutoSave to trigger editor.formatOnSave even when files.autoSave is set to afterDelay.

The March 2024 release includes the fix for this bag (release date: 4 April 2024).