VS Code: managing extensions across machine | Day in my life

December 20, 2021

VS Code: managing extensions across machine

Do you use VS Code for editing or developing code? Do you use VS Code across multiple machines? Do you like to have extensions across multiple environments the same? If you answered yes to all questions, then here is the solution.

Enable Command Line Tool to access VS Code from the command line (see below). Do this both on the source and target machine.

VS Code add to PATH for command line executions

Executes the following command on the source machine, which exports the installed extensions onto a file.

$ code --list-extension > extensions.list

Execute the following command to install the exported extensions onto the target machine.

$ xargs printf -- '--install-extension %s\n' < extensions.list | xargs code

NOTE: xargs is a *nix command find an alternative for Windows or use Cygwin or WSL

You could also use a settings-sync to sync extensions and config, but it requires creating a GitHub repo for only settings or having a Microsoft account. My workflow is to have a workspace file for each project which stores settings. I add the workspace file to the git repo to track. I seldom have global settings. If I have global settings, it would be specific to that machine, like font size or font family.

© Nataraj Basappa 2021