Is there any way to sync my Visual Studio Code settings between instances?

前端 未结 10 1992
面向向阳花
面向向阳花 2020-12-07 09:17

I\'d like to be able to sync my VS Code user settings (File > Preferences > User Settings) to the cloud somehow so I can easily share them between multiple installatio

相关标签:
10条回答
  • 2020-12-07 10:02

    Use workspace-settings instead of user-settings.

    0 讨论(0)
  • 2020-12-07 10:03

    User Settings

    There is currently no automatic synchronization for user settings available in Visual Studio Code. On Windows the user settings are located in %APPDATA%\Code\User\settings.json. You could save a copy of that file on OneDrive or Dropbox and move it on all your machines to the user settings folder. But this still includes manual steps on each machine every time you change the configuration.

    You can suggest an automatic synchronization of settings here: https://visualstudio.uservoice.com/forums/293070-visual-studio-code

    Workspace Settings

    Add the .vscode folder of your workspace to the version control system (Git/SVN etc). When you checkout the code from the repository you will automatically get the VS Code workspace settings.

    0 讨论(0)
  • 2020-12-07 10:03

    Another way of doing it would be to soft link your files, which can also be stored in a repository on GitHub. For example, on Mac OS let's say you have a directory called ~/dev/dotfiles/vscode. Let's say there are two files in there called settings.json and keybindings.json. You could soft link these files with:

    ln -s ~/dev/dotfiles/vscode/keybindings.json ~/Library/Application\ Support/Code/User/keybindings.json
    ln -s ~/dev/dotfiles/vscode/settings.json ~/Library/Application\ Support/Code/User/settings.json
    

    If you are using Windows or Linux the path to the respective settings directories can be found at https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations

    0 讨论(0)
  • 2020-12-07 10:04

    You can make a hard link from the directory containing user settings to your sync directory of applications such as Dropbox or OneDrive.

    For example, on windows, the user settings are located in %APPDATA%\Code\User, so you could type:

    mklink /H /J X:\Your\Sync\Dir %APPDATA%\Code\User

    on your computers with Visual Studio Code to achieve the synchronization.

    Then, on another computer, you may delete the %APPDATA%\Code\User folder, and type:

    mklink /H /J %APPDATA%\Code\User X:\Your\Sync\Dir

    to retrieve the synchronized settings.

    0 讨论(0)
  • 2020-12-07 10:07

    I did this on my Mac by copying VS Code's settings.json to my iCloud drive for automatic backup, and then creating a symbolic link.

    1. Copy settings.json from VS code settings directory $HOME/Library/Application Support/Code/User/settings.json to your backup location
    2. Backup the old settings.json by renaming to settings-old.json
    3. In the terminal, cd to VS code setting dir: cd ~/Library/Application\ Support/Code/User/
    4. Create the symlink to your backed up file using command ln -sf path/to/backup/settings.json settings.json. Since I backed mine up to iCloud and renamed the file to vscode.settings.json, my command looked like this: ln -sf ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode.settings.json settings.json
    5. Check that you can open up user preferences in VS Code

    To use the backup on a different Mac, just repeat steps 2-5.

    I also did this for extensions...

    cd ~/.vscode/
    mkdir ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode/
    cp -a extensions ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode
    mv extensions extensions-old
    ln -sf ~/Library/Mobile\ Documents/com~apple~CloudDocs/vscode/extensions extensions
    
    0 讨论(0)
  • 2020-12-07 10:12

    This is finally a built-in feature: see Settings Sync in Visual Studio Code.

    0 讨论(0)
提交回复
热议问题