← Other topics

VSCode - Backup and Reset to Default Settings (Mac)

Video Notes

Sometimes you might find your install of VSCode ”broken”. It could be something internal with the program, a bad extension, a rogue setting - whatever the case might be, sometimes a reset can be the best course of action.

In this Mac-specific guide I’ll show you how to first backup your existing settings, keybindings, and extensions, then completely remove VSCode so you can do a fresh install.

Finally, I will cover how you can port in your backed up settings, keybindings, and extensions into your fresh install.

This guide assumes you have the VSCode code shortcut available from command line. If you don’t, open your Command Palette in VSCode (cmd + shift + p) and search for “code” then choose the option Shell Command: Install code command in Path

Backup extensions

To begin, first back up your extensions.

Run the following command to copy a list of your installed extensions to a file on your Desktop called vscode_extensions.txt:

> code --list-extensions >> ~/Desktop/vscode_extensions.txt

Backup settings

Next, run the following command to make a copy of your VSCode settings to a file on your Desktop called vscode_settings.json:

> cat ~/Library/Application\ Support/Code/User/settings.json >> ~/Desktop/vscode_settings.json

Backup keybindings

Next, run the following command to make a copy of your VSCode keybindings to a file on your Desktop called vscode_keybindings.json:

> cat ~/Library/Application\ Support/Code/User/keybindings.json >> ~/Desktop/vscode_keybindings.json

Remove VSCode

Next, run the following command to delete the VSCode application itself:

> rm -rf /Applications/Visual\ Studio\ Code.app

And the following commands to delete meta files and settings/extensions/keybindings associated with VSCode:

rm -fr ~/Library/Preferences/com.microsoft.VSCode.helper.plist 
rm -fr ~/Library/Preferences/com.microsoft.VSCode.plist 
rm -fr ~/Library/Caches/com.microsoft.VSCode
rm -fr ~/Library/Caches/com.microsoft.VSCode.ShipIt/
rm -fr ~/Library/Application\ Support/Code/
rm -fr ~/Library/Saved\ Application\ State/com.microsoft.VSCode.savedState/
rm -rf ~/.vscode*

Reinstall VSCode

With your system now cleared of VSCode, it’s time to do a fresh install.

Visit the VSCode homepage to download and install a fresh copy.

Restore settings

When restoring your settings on your fresh VSCode install you can either restore them all exactly as they were in your backup, or you can manually pull in one setting at a time. The latter approach is suggested if you suspect something in your settings was part of the problem that motivated you to restore VSCode in the first place. Both options are covered below...

Option 1 - Full settings restore

To do a full restore from your backup file (~/Desktop/vscode_settings.json), run the following command:

> cat ~/Desktop/vscode_settings.json >> ~/Library/Application\ Support/Code/User/settings.json

Option 2 - Selective settings restore

To restore settings individually, manually copy each line of ~/Desktop/vscode_settings.json into ~/Library/Application\ Support/Code/User/settings.json one by one, testing things are working as expected as you go.

Restore keybindings

The procedure for restoring keybindings is the same as restoring settings.

Option 1 - Full keybindings restore To do a full restore from your backup file (~/Desktop/vscode_keybindings.json), run the following command:

> cat ~/Desktop/vscode_keybindings.json >> ~/Library/Application\ Support/Code/User/keybindings.json

Option 2 - Selective keybindings restore

To restore settings individually, manually copy each line of ~/Desktop/vscode_keybindings.json into ~/Library/Application\ Support/Code/User/keybindings.json one by one, testing things are working as expected as you go.

Restore extensions

Like your settings, you might want to restore all your extensions at once, or you might want to do it one extension at a time. Both options are covered below...

Option 1 - Complete extensions restore

To restore all your extensions at once, run the following command:

>  cat ~/Desktop/vscode_extensions.txt | xargs -n 1 code --install-extension

Option 2 - Selective extensions restore

To restore extensions individually, open ~/Desktop/vscode_extensions.txt and go through each extension listed - searching and installing in VSCode.

Conclusion

That’s it! You should now have a fresh install of VSCode fully restored to all your previous extensions and settings (sans any extensions your settings that may have been causing your initial issues!)

If this info helped you out you can say thanks and support future content by clicking my Amazon affiliate link: https://amzn.to/3UtgnYk. If you make a purchase on Amazon within 24 hours of clicking the link I may receive a micro-commission and it costs you nothing extra. Any income from these sales goes directly to supporting me in making new videos and guides. Thank you for your support!

← Other topics