programing tip

인스턴스간에 내 Visual Studio Code 설정을 동기화하는 방법이 있습니까?

itbloger 2020. 8. 10. 07:46
반응형

인스턴스간에 내 Visual Studio Code 설정을 동기화하는 방법이 있습니까?


VS Code 사용자 설정 (파일> 기본 설정> 사용자 설정)을 어떻게 든 클라우드에 동기화하여 Windows 10 및 Visual Studio에서와 같이 여러 설치간에 쉽게 공유 할 수 있기를 원합니다.

이 작업을 지원하는 방법이 있습니까? 코드에서 직접 지원하는 것도 좋지만, 그렇지 않으면 settings.json 위치를 Dropbox 또는 OneDrive 폴더로 옮길 수도 있습니다.

저는이 작업을 자동으로 조용히 수행하는 방법을 구체적으로 찾고 있습니다. 수동 내보내기 / 가져 오기는 너무 번거롭고 내가 찾고있는 것이 아닙니다.


업데이트 : 여기에 기능 요청이 있습니다 . 이 기능을 원하시면 좋아요를 눌러주세요.


여러 인스턴스에서 모든 Visual Studio 코드 설정을 동기화하는 확장을 개발했습니다.

주요 특징들

  1. github 계정 토큰을 사용하십시오.
  2. 한 번의 클릭으로 업로드 및 다운로드가 쉽습니다.
  3. 모든 설정 및 스 니펫 파일을 저장합니다.
  4. 업로드 키 : Shift + Alt + u
  5. 다운로드 키 : Shift + Alt + d
  6. 모든 동기화 옵션을 보려면 동기화를 입력하십시오.

그것은 동기화

  1. 설정 파일
  2. 키 바인딩 파일
  3. 파일 시작
  4. 스 니펫 폴더
  5. VSCode 확장

상세 문서 소스

VSCode 동기화 추가 정보

여기에서 다운로드 : VS 코드 설정 동기화


사용자 설정이 포함 된 디렉터리에서 Dropbox 또는 OneDrive와 같은 응용 프로그램의 동기화 디렉터리로 하드 링크를 만들 수 있습니다.

예를 들어 Windows에서 사용자 설정은에 %APPDATA%\Code\User있으므로 다음을 입력 할 수 있습니다.

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

Visual Studio Code를 사용하여 컴퓨터에서 동기화를 수행합니다.

그런 다음 다른 컴퓨터에서 %APPDATA%\Code\User폴더를 삭제 하고 다음을 입력 할 수 있습니다 .

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

동기화 된 설정을 검색합니다.


아하, 내 VSCode 확장 : Syncing .

당신이 그것을 좋아하기를 바랍니다. :)


퀵 가이드

  1. 동기화 설치 :

  2. 나만의 것을 얻으십시오 GitHub Personal Access Token:

    1. GitHub Settings 페이지에 로그인 하십시오.

      설정 페이지에 로그인

    2. Personal access tokens탭을 선택 하고을 클릭 Generate new token합니다.

      새 토큰 생성

    3. 를 선택 gist하고 클릭 Generate token합니다.

      요점을 허용하다

    4. 토큰을 복사하고 백업하십시오.

      토큰 복사 및 백업

  3. 설정 동기화 :

    Syncing필요한 정보 for the first timesave for later use.

    1. 업로드 :

      1. 입력 upload에서 VSCode Command Palette.

      2. 귀하의 입력 GitHub Personal Access Token.

      3. 귀하의 Gist ID(또는 leave it blank자동 생성)을 입력하십시오 .

      4. 끝난!

      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!


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

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.


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')

이를 수행하는 또 다른 방법은 GitHub의 리포지토리에 저장할 수있는 파일을 소프트 링크하는 것입니다. 예를 들어, Mac OS에서라는 디렉토리가 있다고 가정 해 보겠습니다 ~/dev/dotfiles/vscode. 의이라고 거기에 두 개의 파일이 있다고 가정 해 봅시다 settings.jsonkeybindings.json. 이러한 파일을 다음과 소프트 링크 할 수 있습니다.

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

Windows 또는 Linux를 사용하는 경우 각 설정 디렉토리의 경로는 https://code.visualstudio.com/docs/getstarted/settings#_settings-file-locations 에서 찾을 수 있습니다.


사용자 설정 대신 작업 공간 설정을 사용하십시오.

참고 URL : https://stackoverflow.com/questions/33392127/is-there-any-way-to-sync-my-visual-studio-code-settings-between-instances

반응형