Sync VSCode settings and snippets via dotfiles on Github
My text editor and the browser are probably the most frequently used applications in my daily work routine. As long as you are logged in to Google Chrome (or any other browser) the synchronization of settings and plugins happens in the background. Unfortunately syncing settings between applications like VSCode is not as straight forward. However, just because it doesn’t come baked into the software it doesn’t mean it is impossible.
As a long term Sublime Text user I managed to use Github to sync its settings across multiple machines via .dotfiles. I used Atom for a little while and I found a way to mimic this mechanism for it as well. I published an article about it the other day. Today it is time to show you how to do it with VSCode. By the way - VSCode is awesome!
Moving VSCode settings to .dotfiles
The folder in which your VSCode settings and snippets reside depends on the operating system. User and Workspace Settings and its locations are described in the official documentation. As a macOS user I will provide some snippets associated with this operating system, but if you are a Windows or Linux user feel free to follow along and replace the paths accordingly. Before pasting anything into your Terminal make sure to shut down VSCode.
OK, let’s move the settings files and the directory containing your snippets to your .dotfiles that is located in the root folder.
mv ~/Library/Application\ Support/Code/User/settings.json ~/.dotfiles/VSCode/ mv ~/Library/Application\ Support/Code/User/keybindings.json ~/.dotfiles/VSCode/ mv ~/Library/Application\ Support/Code/User/snippets/ ~/.dotfiles/VSCode/
Create symbolic links to VSCode settings file directory
All that we need is in the correct location now, time to create symlinks to those files.
ln -s /Users/pawelgrzybek/.dotfiles/VSCode/settings.json /Users/pawelgrzybek/Library/Application\ Support/Code/User/settings.json ln -s /Users/pawelgrzybek/.dotfiles/VSCode/keybindings.json /Users/pawelgrzybek/Library/Application\ Support/Code/User/keybindings.json ln -s /Users/pawelgrzybek/.dotfiles/VSCode/snippets/ /Users/pawelgrzybek/Library/Application\ Support/Code/User
Boom! And it’s done! Easy eh? Now you can commit the new “Code” directory to your .dotfiles repo, create symbolic links across all your machines and enjoy version controlled settings and snippets.
If you have any idea how to sync the list of plugins installed from VS Code Marketplace please let me know in the comments. Have a great day :*
Have you seen https://marketplace.visuals... yet? Under the hood it’s also using GitHub (gists in this case) to keep a backup of all of your settings (keymaps, settings.json, extensions, etc.).
Hi @lukaszklis:disqus. I saw it — very cool tool. I used the same kind of thing for Atom. Really cool solution. It is just my personal preference to store things like this in .dotfiles repo as I store tons of configs for other apps in there.
Did you switch to VSCode as well? As I remember you've been long term vim user. Is that right?
Since August last year I’ve switched to an IDE (IntelliJ IDEA Ultimate)—it’s just simpler for projects’ setup I work on. :) On the side, I use VSCode, and I still have my vim’s dotfiles. :)
Very helpful. Thank you. I was just playing around this this, and it seems to work.
To get the extensions, it looks like you can sync the ~/.vscode directory using the same symlink method that you describe.
I don't symlink my extension on purpose. It is much easier to list / install / uninstall them using code CLI.
Thanks a lot for nice comment and have a nice day 🥑