Batch install extensions for Visual Studio Code
So, you move to another machine (permanently or temporarily) and need your favorite editor to behave the same. How to easily take the installed extensions with you?
When you try to google vscode synchronization you are presented with an extension called Settings Sync that can pretty much cover this problem and do even more. In my laziness, I found the set up a bit complex as I only wanted to get all extensions from my old device and install them to the new one. Once and for all. Preferably without any GitHub token fiddling around.
OK, let’s make it quick; we can do that just with a few commands. Open your terminal and execute:
code --list-extensions > extensions.md
This will put the list of your VSCode extensions in the extensions.md
file, one name per line.
Side note: I use markdown for almost all text-only files currently, but clearly, it can be anything.
Now you need to move this file to your new machine. Use Dropbox, Drive, email, USB stick, whatever suits you most. Finally, execute:
xargs -n1 code --install-extension < extensions.md
xargs
will execute code --install-extension
for provided input. More precisely, argument -n1
means that a command is executed one-by-one for every line of the input file. First item may produce code --install-extension esbenp.prettier-vscode
to install Prettier - Code formatter.
And that’s it! You have successfully installed all your extensions with only two commands.
For more info check all VSCode commands for managing extensions. For evidence, here is the list of my extensions:
- Nette Latte + Neon
- Markdown TOC
- Markdown Checkboxes
- Tailwind CSS IntelliSense
- Better TOML
- Bracket Pair Colorizer
- GitLens — Git supercharged
- EditorConfig for VS Code
- Material Theme
- Prettier - Code formatter
- PHP IntelliSense
- Code Runner
- REST Client
- Diff Tool
- vscode-styled-components
- GraphQL for VSCode
- Git Graph
- DotENV
- Apache Conf
- Docker
- Live Share
- Debugger for Chrome
- GraphQL
- Live Server
- Nunjucks
- MDX
- Sort lines
- vscode-icons
- Quokka.js
- TODO Highlight