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

前端 未结 10 1993
面向向阳花
面向向阳花 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:13

    Aha, you can try my VSCode extension: Syncing.

    Hoping you'll like it. :)


    A Quick Guide

    1. Install Syncing:

    2. Get your own GitHub Personal Access Token:

      1. Login to your GitHub Settings page.

      2. Select Personal access tokens tab and click Generate new token.

      3. Select gist and click Generate token.

      4. Copy and backup your token.

    3. Sync your settings:

      Syncing will ask for necessary information for the first time and save for later use.

      1. Upload:

        1. Type upload in VSCode Command Palette.

        2. Enter your GitHub Personal Access Token.

        3. Enter your Gist ID (or leave it blank to create automatically).

        4. Done!

        5. After uploading, you can find your settings and the corresponding Gist ID in your GitHub Gist.

      2. Download:

        1. Type download in VSCode Command Palette.

        2. Enter your GitHub Personal Access Token (or leave it blank if you want to download from a public Gist)

        3. Enter your Gist ID (or a public Gist ID).

        4. Done!

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

    I place my settings.json in a configuration file that I sync with git (though Dropbox would also work) and use a Python script to symlink it to the correct location for each platform so updating it from the settings menu syncs across my machines. Creating symlinks requires admin privileges on Windows.

    import os
    import platform
    
    # Find the settings file in the same directory as this script
    SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
    VS_SETTINGS_SRC_PATH = os.path.join(SCRIPT_DIR, 'settings.json')
    
    # https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations
    if platform.system() == 'Windows':
        VS_SETTINGS_DST_PATH = os.path.expandvars(r"%APPDATA%\Code\User\settings.json")
    elif platform.system() == "Darwin":
        VS_SETTINGS_DST_PATH = os.path.expandvars(r"$HOME/Library/Application Support/Code/User/settings.json")
    elif platform.system() == "Linux":
        raise NotImplementedError()
    else:
        raise NotImplementedError()
    
    # On Windows, there might be a symlink pointing to a different file
    # Always remove symlinks
    if os.path.islink(VS_SETTINGS_DST_PATH):
        os.remove(VS_SETTINGS_DST_PATH)
    
    choice = input('symlink %r -> %r ? (y/n) ' % (VS_SETTINGS_SRC_PATH, VS_SETTINGS_DST_PATH))
    if choice == 'y':
        os.symlink(VS_SETTINGS_SRC_PATH, VS_SETTINGS_DST_PATH)
        print('Done')
    else:
        print('aborted')
    
    0 讨论(0)
  • 2020-12-07 10:21

    I have developed an extension that will sync all your Visual Studio Code Settings across multiple instances.

    Key Features

    1. Use your GitHub account token.
    2. Easy to Upload and Download on one click.
    3. Saves all settings and snippets files.
    4. Upload Key : Shift + Alt + u
    5. Download Key : Shift + Alt + d
    6. Type Sync In Order to View all sync options

    It Sync

    • Settings File
    • Keybinding File
    • Launch File
    • Snippets Folder
    • VSCode Extensions

    Detail Documentation Source

    VSCode - Settings Sync blog post

    Download here : VS Code - Settings Sync - Extention

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

    In v1.48:

    Preview features

    Preview features are not ready for release but are functional enough to use. We welcome your early feedback while they are under development.

    Settings Sync

    Settings Sync is now available for preview in the stable release

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