Change VSCode User Settings location

2020-05-22 07:30发布

I want to put my User Settings file under version control, preferably a separate folder, but I can't find the option to tell VSCode where my settings file is located.

Is there a way to change the location that Visual Studio Code looks for the settings.json file?

Update:

Since there does not seem to be a easy way to change the default location of the user settings file, besides passing the command line arguments as in this answer, I went with a different approach.

I created a git repository which contains all of my dotfiles, settings-files, etc. and put my settings.json there. This repository is cloned somewhere on the development partition of my hard drive. I then created a Symlink using the mklink.exe tool (I am on Windows) to the settings file in my repository in the default user settings directory (path-to-user/AppData/Roaming/Code/User/ on Windows). The only drawback is that you can't move the repository, or change its layout without having to recreate the link.

Changing the Symlink to a Hardlink is not advised as explained in this blog-post. Also Hardlinks seem to mess up the timestamps on Windows, so you won't see any changes made to settings.json from within VSCode. The Symlink seems to be working tho.

2条回答
老娘就宠你
2楼-- · 2020-05-22 08:17

You can set the location of the global user data folder by launching from the command line with the --user-data-dir option. But I just initialized a git repo in the default user settings location and keep it in source control there.

查看更多
虎瘦雄心在
3楼-- · 2020-05-22 08:19

You can add a settings file for a workspace like this :

/yourproject/.vscode/settings.json

Or use the editor and goto :Preferences->settings and select workspace settings in the top bar.

These can be checked into your project and then to source control.

Reference : https://code.visualstudio.com/docs/getstarted/settings#_creating-user-and-workspace-settings

The file is created for you by default when editing the settings in your workspace. There you can select User or Workspace settings.

You can also open the Settings editor from the Command Palette (⇧⌘P) with Preferences: Open Settings or use the keyboard shortcut (⌘,).

enter image description here

查看更多
登录 后发表回答