visual-studio-code

How do I fully reset VS Code?


I am new to programming and after following a bunch of tutorials on how to setup VS Code, i feel like all the things are now countering each other and sometimes the code works, sometimes it doesn't, sometimes it give an error, sometimes it runs and sometimes it doesn't even register the changes I make.

The code is good, it's working in online compilers, but the issue is with VS Code so I am looking for a way to fully clean it out, no residual extensions, no changed settings, nothing. I tried to uninstall and reinstall but that didn't do anything.


Solution

  • Introduction

    The answer about settings is incorrect. Settings is a minor thing. There is a lot more information VSCode operation leaves behind.

    Most of this information is cache of different kinds, User global storage and user workspace storage. Even if you reinstall VSCode and reset all settings, this data may still bug you. For example, VSCode will remember opened files in all your workspaces, active tabs, and so on. If you delete some files previously opened in some workspace, and later open this workspace again, you can get an error message showing that the file does not exist.

    Background

    This cached data is very important. First and foremest, note that you can close the VSCode session anytime, even if you have unsaved files. Obviously, there is no information on the changes in your workspace directory. However, the content of those files is cached, so you can restore it when you open the worspace again.

    How to locate this data?

    This is called User Data. Its location depends on different factors: platform and the type of the installation. The installation can be portable, obtained by just unpacking a ZIP file, or not. Let's see how to locate it.

    Use the command (F1) Developer: Open User Data Folder.

    You will see the User Data directory, it's name is data.

    Inside this directory, you will see (at least) two important sub-directories: extensions and user-data. Let's say, you don't want to touch extensions. Then you can consider removing the entire data/user-data directory, or a part of it. You can do it. That brings us to the next section.

    What can you remove?

    You can safely remove the entire directory data/user-data. Next time you work with VSCode, this directory will be restored, as well as all required data. But all your setting will be lost, as well as the information on every existing worspace. In many cases, this is what you want. You can screw up many setting and want to start over. This is your choice then.

    Note that you still have settings stored in each workspace in your .vscode directories. In particular, setting.json store the part of the settings corresponding the tab `Worspace'. (Please see [Main menu] > File > Preferences > Settings.)

    You can use a more fine-grain approach and remove only the part of data. First of all, you can safely remove all the directories with the word "cache" in their names. More importantly, you may want to remove data/user-data/User/globalStorage and data/user-data/User/workspaceStorage. For example the first directory stores source trust information, and the second one stores the status of the files, positions, tabs, and so on. If you remove or relocate a worspace directory, you may want to get rid of redundant data.

    Should you remove worspace data?

    Yes! You have some good reasons to do it anyway. First, during your work, you collect a lot of redundant information. If you delete some directories corresponding your workspaces or multi-worspace directories, the status data related to these directories is still stored, as well, as other options, for example, when you answer some questions in the dialogs.

    If you get lost, you can safely remove data/user-data, get rid of redundant data and get back to defaults. You can preserve the most important setting in a separate backup directory, remove all VSCode data and later restore this valuable data from your backup.

    Usage note

    Even though the operation related to the User Data is pretty robust, I can see some problems here. The names of the directories inside data/user-data and the related functionality is not documented. In next version, this functionality may change.

    At the same time, accumulation of the redandant information is a problem. As you work with more and more directories, the volume of data grows, and this volume can be considerable. I personally clean it up on a regular basis.

    At the same time, even if you remove the entire data/user-data or even the entire data directory, it won't be too bad. Please see the end of the previous section.

    A note on extensions

    As far as I understand, you don't want to touch extensions. I just want to note that the directory data/extensions can also be used. If you rename it, it disables all the extensions at once, and this is the simplest way to remove them temporarily. You also can manually move the sub-directoroes of this directory, and this is a fastest way to temporarily remove and re-enable separate extensions. You can even use this directory as a quick way of manual extension installation.

    And yes, it is safe, because you can always remove them all and install in a usual way again.