I'm trying to setup my visual studio code editor to auto save files on focus change.
Reading the setting documentation, I've set up my setting.json file for the project like this:
// Place your settings in this file to overwrite default and user settings.
{
"files.exclude": {
"**/*.js": { "when": "$(basename).ts"},
"files.autoSave": "onFocusChange"
}
}
But when I make changes to a file, then switch to a different file nothing happens (I still have to save the file manually).
What am I doing wrong?
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.
Show extension side bar within VS Code(Mac: Command + Shift + X , Windows and Linux: Ctrl + Shift + X ), type unsaved-files-vscode and press Enter and click Install .
AutoSave in Visual Studio 2022 Navigate from Tools > Options > Environment > Preview Features and Enable the autosave. Once you have Autosave Enabled, when Visual Studio loses focus, all the unsaved documents will be saved.
The option "files.autoSave" should be out of the "files.exclude" section.
"files.exclude": {
"**/*.js": { "when": "$(basename).ts"}
},
"files.autoSave": "onFocusChange"
In VS Code, Enable the function using File > Auto Save
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