Reputation: 100010
I have used WebStorm from JetBrains for almost four years now. It's a fantastic IDE for many reasons, but one of the best features is that it saves versions of files outside of version control. So if you accidentally delete files or lose files before they are saved by your version control system, WebStorm has a copy of them and there are visual diff tools to use. This feature has saved me on more than one occasion.
For Visual Studio Code, is there some feature/plugin that will auto-save copies of files as they change? Will Visual Studio Code save the files to some central location, or perhaps in the .vscode
folder in the local workspace?
The feature in WebStorm is available from Local History → Show History from a folder or file. Here is an article about it: Using Local History for code changes tracking
The view looks like:
Upvotes: 240
Views: 262720
Reputation: 9658
You can enable auto save with one of this methods:
Method 1. Check the Auto Save item in the File menu
Method 2. Go to Settings, search for auto save, and select the auto save option (afterDelay)
Auto save description in Visual Studio Code documentation
Upvotes: 129
Reputation: 1756
As of March 2022 (version 1.66), Visual Studio Code has a built-in feature called Local History that automatically creates commit-like versions of your files on every save.
It is enabled by default, but you can double check the setting workbench.localHistory.enabled to make sure it is enabled in your project.
From the reference:
Each local history entry contains the full contents of the file at the time the entry was created and in certain cases, can provide more semantic information (for example, indicate a refactoring).
From an entry you can:
- Compare the changes to the local file or previous entry.
- Restore the contents.
- Delete or rename the entry.
The saved local versions are accessible from the Timeline section in the File Explorer tab.
Upvotes: 8
Reputation: 21
Also, ensure you add .history to your .gitignore file, so Visual Studio Code doesn't track every change made to a single file as changes made to multiple files. This can be a problem and make your files changed so large even though it's a single file or a few files you made edits to.
Upvotes: 1
Reputation: 1739
Yes, Visual Studio Code can auto-save changes on files as you make changes. It also allows you set a delay for how long to wait before saving the file.
Here's a link that should help you with that.
Or a shortcut you can simply navigate to your Visual Studio Code settings, and add the following to your settings.json
file.
{
...
"files.autoSave": "afterDelay",
"files.autoSaveDelay": 1000,
...
}
This will instruct your editor to autosave after a 1000 ms delay. You can set the autosave option to onFocusChange
to autosave whenever you move your cursor away from the current text area.
Upvotes: 44
Reputation: 1739
There's a package called Local History that can be used to save a backup of your files outside version control.
You should check that out.
Upvotes: 17