Automatically install extensions in VS Code? - visual-studio-code

Is there some way to automatically install VS Code extensions when opening a project (like package.json but for vscode?)
If not, is there some way to install extensions at the command line?

Neither of those are currently possible. I created an issue some time ago for installing extensions via the command line, be sure to give it a +1 to show your interest.
Update
The recommended way of doing this is through workspace recommended extensions, this is a .vscode/extensions.json in your project that will prompt the user to install them when they first open the folder, the file looks like this:
{
"recommendations": [
"eg2.tslint",
"dbaeumer.vscode-eslint",
"msjsdiag.debugger-for-chrome"
]
}
You can also try setting up a bash/bat script or some other automation to directly install the extensions using the CLI as suggested by parsley72 in the other answer. You will likely annoy users by doing this though, unless this is in a personal dotfiles project or something similar.

The issue that #daniel-imms created was resolved in June 2017. You can see this in the latest version:
$ code -h
Visual Studio Code 1.16.0
Usage: code [options] [paths...]
Options:
--extensions-dir <dir> Set the root path for extensions.
--list-extensions List the installed extensions.
--show-versions Show versions of installed extensions, when using --list-extension.
--install-extension (<extension-id> | <extension-vsix-path>) Installs an extension.
--uninstall-extension <extension-id> Uninstalls an extension.
--enable-proposed-api <extension-id> Enables proposed api features for an extension.
--disable-extensions Disable all installed extensions.

Thanks to Daniel's suggestion, and I find if you want to keep a list of vscode extensions and install all of them in single click, you can try this approach:
Create the list of extensions you want using the workspace recommended extensions
Use the Configure Recommended Extensions command to create the extensions.json file
You will create a file like this:
{
// See https://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"ms-vscode.cpptools",
"file-icons.file-icons",
"shd101wyy.markdown-preview-enhanced",
"sagebind.mathpad",
"johnpapa.vscode-peacock"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
Add your favorite vscode extension id into the list in JSON
Re-launch vscode to open the workspace folder (the parent folder for .vscode folder)
Navigate to "Extensions", filter extensions using "Recommended" filter
A list of extensions will be shown in "Workspace Recommendations"
Click the ☁️ button to install all extensions at once

See https://code.visualstudio.com/docs/editor/extension-gallery#_command-line-extension-management
I wrote this Makefile to automatically install extensions
freeze-extensions:
code --list-extensions > extensions.txt
install-extensions:
cat extensions.txt | xargs -L 1 code --install-extension

For projects where Node.JS/npm is available, this one-liner(-ish) will install all recommended extensions for the workspace via the command line in a single step:
npx json5 .vscode/extensions.json | \
npx json-cli-tool --path=recommendations --output=newline | \
xargs -L 1 code --install-extension
You could imagine documenting this step in a README's local development setup instructions.
Breakdown of the command:
It uses npx, which will install the json-cli-tool and json5 packages from npm if they're not already installed.
# Compile the extensions.json file from JSON (with comments) to valid JSON
# That's because VS Code's setting files often contain comments
# If yours doesn't, you can skip this step
npx json5 .vscode/extensions.json | \
# Traverse the JSON and extract all extension names
# on a new line from the "recommendations" array
npx json-cli-tool --path=recommendations --output=newline | \
# Which should output:
# "dbaeumer.vscode-eslint"
# "stylelint.vscode-stylelint"
# Pass each line from the command above to VS Code's CLI
# as seen in [#weaming's solution][2]
xargs -L 1 code --install-extension

Related

Taking inventory of VS Code Extensions across multiple computers?

If you have multiple developers w/ multiple developer workstations and they each have VS Code, how can I track what extensions that have from a central location? I don't want to have to sign on to each workstation one at a time and pull up VS Code for a list of installed extensions and versions. FOr example, there is a vulnerability in VS Code's TS-Lint extension. How can I tell what computers in my group have that installed?
Method 1: Query the File System
The Common Questions section of the page Managing Extensions in Visual Studio Code shows where extensions are installed:
Where are extensions installed?
Extensions are installed in a per user extensions folder. Depending on your platform, the location is in the following folder:
Windows: %USERPROFILE%\.vscode\extensions
macOS: ~/.vscode/extensions
Linux: ~/.vscode/extensions
The extensions directory contains one subdirectory for each installed extension, named like (extension)-(version). Listing its contents for each user and machine should provide a comprehensive list of installed extensions.
Method 2: Query VSCode Itself
Another approach is to use the VSCode command line as explained in the Command Line Extension Management of that same page. In particular, you can run:
$ ./bin/code --list-extensions --show-versions
from the VSCode install directory when logged in as a particular user to get a list of (extension)#(version) strings.
But note: you have to use the code program in the bin subdirectory of VSCode, which is a shell script (requiring Cygwin on Windows). On Windows at least, there is also Code.exe in the top-level VSCode directory, but that one does not respect those command line flags.

How to install multiple extensions in VSCode using command line

How can I install multiple extensions in VSCode using the cli? I tried:
code --install-extension xyz.local-history jock.svg
but it only installs the first extension xyz.local-history.
Installing extensions...
Installing extension 'xyz.local-history' v1.7.0...
(node:10874) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
Extension 'xyz.local-history' v1.7.0 was successfully installed.
If you are use Unix/Linux create a bash script with a loop. In this case I want to backup the extensions list and install again:
First create a list of the extensions:
$ code --list-extensions > extensions.txt
Create a bash script for example with the name vscode-extension-install.sh and input the following code:
#!/usr/bin/env bash
cat extensions.txt | while read extension || [[ -n $extension ]];
do
code --install-extension $extension --force
done
Then run:
$ ./vscode-extension-install.sh
Example output:
Installing extensions...
Installing extension 'visualstudioexptteam.vscodeintellicode' v1.2.6...
Extension 'visualstudioexptteam.vscodeintellicode' v1.2.6 was successfully installed.
Installing extensions...
Installing extension 'vscode-icons-team.vscode-icons' v10.0.0...
Extension 'vscode-icons-team.vscode-icons' v10.0.0 was successfully installed.
...
From my gists
Declare a variable, containing the name of all extensions you want to install... after you have it, you can iterate doing the installation one by one...
for extensions in ms-python.python ms-azure-devops.azure-pipelines ms-mssql.mssql
do code --install-extension $extensions
done
Maybe you also have to add your code.cmd path, but if your command is working typring code, this will be enough to do the taks
Happy coding!
If you are on Windows and do not use WSL, try a PowerShell loop.
Put all desired extensions in a text file (as in Linux example above) - say extensions.txt
Iterate over them with:
Get-Content extensions.txt | ForEach-Object {code --install-extension $_}
Note: this would work on every system supporting PowerShell
It's possible to pass the --install-extension argument multiple times and so install several extensions with just one line.
code --install-extension dbaeumer.vscode-eslint --install-extension esbenp.prettier-vscode
The documentation for this can be found in Extension Marketplace. Running this both extensions are installed but Installing extensions... is only found once in the output.
Disclaimer: This is not a command line approach, but rather a graphical way to install existing extensions on a new system using .vsix package, and might help some others with the same.
This method to install extensions on a new system (with reference to an existing system) requires Yeoman VS Code extension generator and vsce (or nodejs to install these).
On the existing machine, generate an extension pack (more details here)
npm install -g yo generator-code
yo code
First command installs Yeoman VS Code generator, second creates the extension pack (choose default options as below. The created package.json contains all extensions in the pack, you can modify that list)
On the existing machine, package the extension pack created above into a .vsix file
npm install -g vsce
vsce package
First command installs vsce, second packages the extension into a .vsix file (run from the root of the extension pack created above)
On the new system, install the .vsix file
code --install-extension extension-pack-0.0.1.vsix
Open VS Code on the new system, access this extension, install all required extensions via GUI
Might be useful to others.
I keep a dump of all extensions in text file for example:
code --install-extension aaron-bond.better-comments
code --install-extension abusaidm.html-snippets
code --install-extension afractal.node-essentials
code --install-extension anseki.vscode-color
code --install-extension be5invis.vscode-icontheme-nomo-dark
....
I would copy all contents of text file and then paste all the contents to PowerShell and then it would install plugins one by one.

No commands matching with 'Enable Custom CSS and JS'

I was trying to add a theme to my VS CODE and i needed to run the command: Enable Custom CSS and JS in the ctrl+shift+P. But when I type it, it says that there are no commands matching. Is there another way to do it?
I added the import in the settings.json like:
"vscode_custom_css.imports": [
"directoy/to/css"
]
but I can't apply.
From the extension's doc:
VERY IMPORTANT: Items in vscode_custom_css.imports must be URLs. Plain file paths are NOT URLs.
Windows File URL Example: file:///C:/Users/MyUserName/Documents/custom.css
The C:/ part is REQUIRED.
MacOS and Linux File URL Example: file:///Users/MyUserName/Documents/custom.css
Windows users
In Windows, make sure you run your VS Code in Administrator mode before enabling or disabling your custom style!
Mac and Linux users
The extension would NOT if Code cannot modify itself. The cases include:
Code files being read-only, like on a read-only file system or,
Code is not started with the permissions to modify itself.
You need to claim ownership on Code's installation directory, by running this command:
sudo chown -R $(whoami) <Path to Code>
The placeholder means the path to VSCode installation. It is typically:
/Applications/Visual Studio Code.app/Contents/MacOS/Electron, on MacOS;
/Applications/Visual Studio Code - Insiders.app/Contents/MacOS/Electron, on MacOS when using Insiders branch;
/usr/share/code, on most Linux;
/opt/visual-studio-code/ on Arch Linux.
Mac and Linux package managers may have customized installation path. Please double check your path is correct.

How can you export the Visual Studio Code extension list?

I need to send all my installed extensions to my colleagues. How can I export them?
The extension manager seems to do nothing... It won't install any extension.
Automatic
If you are looking forward to an easy one-stop tool to do it for you, I would suggest you to look into the Settings Sync extension.
It will allow
Export of your configuration and extensions
Share it with coworkers and teams. You can update the configuration. Their settings will auto updated.
Manual
Make sure you have the most current version of Visual Studio Code. If you install via a company portal, you might not have the most current version.
On machine A
Unix:
code --list-extensions | xargs -L 1 echo code --install-extension
Windows (PowerShell, e. g. using Visual Studio Code's integrated Terminal):
code --list-extensions | % { "code --install-extension $_" }
Copy and paste the echo output to machine B
Sample output
code --install-extension Angular.ng-template
code --install-extension DSKWRK.vscode-generate-getter-setter
code --install-extension EditorConfig.EditorConfig
code --install-extension HookyQR.beautify
Please make sure you have the code command line installed. For more information, please visit Command Line Interface (CLI).
I've needed to do this myself a few times - especially when installing on another machine.
Common questions will give you the location of your folder
Visual Studio Code looks for extensions under your extensions folder .vscode/extensions. Depending on your platform it is located:
Windows %USERPROFILE%\.vscode\extensions
Mac ~/.vscode/extensions
Linux ~/.vscode/extensions
That should show you a list of the extensions.
I've also had success using Visual Studio Code Settings Sync Extension to sync settings to GitHub gist.
In the latest release of Visual Studio Code (May 2016), it is now possible to list the installed extensions on the command line:
code --list-extensions
Windows (PowerShell) version of Benny's answer
Machine A:
In the Visual Studio Code PowerShell terminal:
code --list-extensions > extensions.list
Machine B:
Copy extension.list to the machine B
In the Visual Studio Code PowerShell terminal:
cat extensions.list |% { code --install-extension $_}
I have developed an extension which will synchronise your all Visual Studio Code settings across multiple instances.
Key Features
Use your GitHub account token.
Easy to upload and download on one click.
Saves all settings and snippets files.
Upload key: Shift + Alt + U
Download key: Shift + Alt + D
Type Sync In Order to View all sync options
It synchronises the
Settings file
Keybinding file
Launch file
Snippets folder
Visual Studio Code extensions
Detail Documentation Source
Visual Studio Code Sync ReadMe
Download here: Visual Studio Code Settings Sync
I used the following command to copy my extensions from Visual Studio Code to Visual Studio Code insiders:
code --list-extensions | xargs -L 1 code-insiders --install-extension
The argument -L 1 allows us to execute the command code-insiders --install-extension once for each input line generated by code --list-extensions.
For Linux
On the old machine:
code --list-extensions > vscode-extensions.list
On the new machine:
cat vscode-extensions.list | xargs -L 1 code --install-extension
If using bash, you can use the following commands:
Export extensions
code --list-extensions |
xargs -L 1 echo code --install-extension |
sed 's/$/ --force/' |
sed '$!s/$/ \&/' > install-extensions.sh
With bash alias, just run eve:
# eve - export vscode extensions
alias eve="code --list-extensions |
xargs -L 1 echo code --install-extension |
sed 's/$/ --force/' |
sed '\$!s/$/ \&/' > install-extensions.sh"
Install extensions
sh install-extensions.sh
Dump extensions:
code --list-extensions > extensions.txt
Install extensions with Bash (Linux, OS X and WSL):
cat extensions.txt | xargs code --list-extensions {}
Install extensions on Windows with PowerShell:
cat extensions.txt |% { code --install-extension $_}
https://code.visualstudio.com/docs/editor/extension-gallery#_workspace-recommended-extensions
A better way to share extension list is to create workspace-based extension set for your colleagues.
After generating a list of extensions via code --list-extensions | xargs -L 1 echo code --install-extension (check your $PATH contains Visual Studio Code entry C:\Program Files\Microsoft VS Code\bin\ before running code commands), run Extensions: Configure Recommended Extensions (Workspace Folder) Visual Studio Code command (Ctrl + Shift + P) and put extensions into the generated .vscode/extensions.json file:
{
"recommendations": [
"eg2.tslint",
"dbaeumer.vscode-eslint",
"msjsdiag.debugger-for-chrome"
]
}
Generate a Windows command file (batch) for installing extensions:
for /F "tokens=*" %i in ('code --list-extensions')
do #echo call code --install-extension %i >> install.cmd
Open the Visual Studio Code console and write:
code --list-extensions (or code-insiders --list-extensions if Visual Studio Code insider is installed)
Then share the command line with colleagues:
code --install-extension {ext1} --install-extension {ext2} --install-extension {extN} replacing {ext1}, {ext2}, ... , {extN} with the extension you listed
For Visual Studio Code insider: code-insiders --install-extension {ext1} ...
If they copy/paste it in Visual Studio Code command-line terminal, they'll install the shared extensions.
More information on command-line-extension-management.
How to export your Visual Studio Code extensions from the terminal. Here is git for that. Maybe this helps somebody.
How to export your Visual Studio Code extensions from the terminal
Note: Unix-like systems only.
Export your extensions to a shell file:
code --list-extensions | sed -e 's/^/code --install-extension /' > my_vscode_extensions.sh
Verify your extensions installer file:
less my_vscode_extesions.sh
Install your extensions (optional)
Run your my_vscode_extensions.sh using a Bash command:
bash my_vscode_extensions.sh
There is an Extension Manager extension, that may help. It seems to allow to install a set of extensions specified in the settings.json.
Benny's answer on Windows with the Linux subsystem:
code --list-extensions | wsl xargs -L 1 echo code --install-extension
code --list-extensions > list
sed -i 's/.*/\"&\",/' list
Copy contents of file list and add to file .vscode/extensions.json in the "recommendations" section.
If extensions.json doesn't exist then create a file with the following contents
{
"recommendations": [
// Add content of file list here
]
}
Share the extensions.json file and ask another user to add to the .vscode folder. Visual Studio Code will prompt for installation of extensions.
Under windows typically I need to run
cd C:\Program Files\Microsoft VS Code\bin
code.cmd --list-extensions
What you don't do is run the code.exe directly under C:\Program Files\Microsoft VS Code\
Now there's a feature still in preview that allows you to sign in with a Microsoft or GitHub account and have your settings synced without any additional extension. It's pretty simple and straigh-forward. You can learn more here.
The things you can sync.
I opened the Visual Studio Code extensions folder and executed:
find * -maxdepth 2 -name "package.json" | xargs grep "name"
That gives you a list from which you can extract the extension names.
For those that are wondering how to copy your extensions from Visual Studio Code to Visual Studio Code insiders, use this modification of Benny's answer:
code --list-extensions | xargs -L 1 echo code-insiders --install-extension
On Windows, using a powershell script. This returns a "FriendlyName" which better reflects the name as it will appear in the Visual Studio Code UI (which code --list-extensions doesn't do):
<#
.SYNOPSIS
Lists installed Visual Studio Code Extensions in a friendly format.
.DESCRIPTION
Lists installed Visual Studio Code Extensions in a friendly format.
.INPUTS
None. You cannot pipe objects to this.
.OUTPUTS
A list of installed Visual Studio Code Extensions in a friendly format.
.EXAMPLE
PS> .\List-Extensions.ps1
.NOTES
Author: John Bentley
Version: 2022-07-11 18:55
Latest at: [How can you export the Visual Studio Code extension list?
> John Bentley's Answer]
(https://stackoverflow.com/a/72929878/872154)
#>
# Change to your directory
$packages = Get-ChildItem C:/Users/John/.vscode/extensions/*/package.json
Function Out-JsonItem($File) {
$json = Get-Content $File | ConvertFrom-Json
$extensionMetaData = [PSCustomObject]#{
# This is the name that appears in the Visual Studio Code UI,
# Extensions Tab
FriendlyName =
if ($json.displayName) { $json.displayName } else { $json.name }
# Name = $json.name
PublisherAndName = $json.publisher + '.' + $json.name
Description = $json.description
}
return $extensionMetaData
}
$extensions = ($packages | ForEach-Object { Out-JsonItem -File $_ })
$extensions.GetEnumerator() | Sort-Object {$_.FriendlyName}
# Alternate sorting (Same order as `code --list-extensions`).
# $extensions.GetEnumerator() | Sort-Object {$_.PublisherAndName}
Example output:
FriendlyName PublisherAndName
------------ ----------------
[Deprecated] Debugger for Chrome msjsdiag.debugger-for-chrome
%displayName% ms-vscode-remote.remote-wsl
Apache Conf mrmlnc.vscode-apache
Apache Conf Snippets eiminsasete.apacheconf-snippets
Auto Close Tag formulahendry.auto-close-tag
Beautify HookyQR.beautify
Blank Line Organizer rintoj.blank-line-organizer
change-case wmaurer.change-case
Character Count stevensona.character-count
...
Word Count ms-vscode.wordcount
Word Count OliverKovacs.word-count
XML redhat.vscode-xml
XML Tools DotJoshJohnson.xml
XML Tools qub.qub-xml-vscode
XPath Notebook for Visual Studio Code deltaxml.xpath-notebook
XSLT/XPath for Visual Studio Code deltaxml.xslt-xpath
Instructions:
Copy script code and save it to a file as List-Extensions.ps1 somewhere (Windows only).
Change the line $packages = Get-ChildItem C:/Users/John/.vscode/extensions/*/package.json to point to your directory (change the user name).
Open Windows Terminal at the directory where you saved List-Extensions.ps1 (the Set-Location command might help here).
Run the script from Windows Terminal with .\List-Extensions.ps1
If you intend to share workspace extensions configuration across a team, you should look into the Recommended Extensions feature of Visual Studio Code.
To generate this file, open the command pallet > Configure Recommended Extensions (Workspace Folder). From there, if you wanted to get all of your current extensions and put them in here, you could use the --list-extensions stuff mentioned in other answers, but add some AWK script to make it paste-able into a JSON array (you can get more or less advanced with this as you please - this is just a quick example):
code --list-extensions | awk '{ print "\""$0"\"\,"}'
The advantage of this method is that your team-wide workspace configuration can be checked into source control. With this file present in a project, when the project is opened Visual Studio Code will notify the user that there are recommended extensions to install (if they don't already have them) and can install them all with a single button press.
If you would like to transfer all the extensions from code to code-insiders or vice versa, here is what worked for me from Git Bash.
code --list-extensions | xargs -L 1 code-insiders --install-extension
This will install all the missing extensions and skip the installed ones. After that, you will need to close and reopen Visual Studio Code.
Similarly, you can transfer extensions from code-insiders to code with the following:
code-insiders --list-extensions | xargs -L 1 code --install-extension
For Linux/Mac only, export the installed Visual Studio Code extensions in the form of an installation script. It's a Z shell (Zsh) script, but it may run in Bash as well.
https://gist.github.com/jvlad/6c92178bbfd1906b7d83c69780ee4630
File > Preferences > Turn on Settings Sync Will sync your VS Code settings across different devices.
I'm using VS Code Version 1.74.0
The other answers require sending a file, which I thought was too fiddly. If you need to send all your extensions to install on another computer, list your extensions with:
code --list-extensions
You can install multiple extensions with a single-line command in this format:
code --install-extension dakshmiglani.hex-to-rgba --install-extension techer.open-in-browser
An easy way to format your list of extensions to create the command is to do a regex search and replace:
Paste your copied list into a new document and search for:
(.+)(\n?)
Replace with --install-extension $1 (Don't omit the space at the
beginning.)
Add the word code to the start of the resulting text and you'll have a very large command that you can hand off to your colleagues to run in their terminal.
code --install-extension hbenl.vscode-test-explorer --install-extension maciejdems.add-to-gitignore --install-extension techer.open-in-browser --install-extension traBpUkciP.vscode-npm-scripts ...
I create an extension for this problem.
This extension allows you to export a list of all currently installed extensions in your Visual Studio Code. The exported list is saved in a JSON file that can be imported later to restore the extensions.
How can you export the Visual Studio Code extension list?
(Ctrl+Shift+P or Cmd+Shift+P) and type
Export Extensions
Import Extensions

How can I export settings?

How is it possible to export all Visual Studio Code settings and plugins and import them to another machine?
With the current version of Visual Studio Code as of this writing (1.22.1), you can find your settings in:
~/.config/Code/User on Linux
%APPDATA%\Code\User (C:\Users\username\AppData\Roaming\Code\User) on Windows
~/Library/Application Support/Code/User/ on Mac OS X
The files are settings.json and keybindings.json. Simply copy them to the target machine.
Your extensions are in:
~/.vscode/extensions on Linux and Mac OS X
%USERPROFILE%\.vscode\extensions (C:\Users\username\.vscode\extensions) on Windows (i.e., essentially the same place as on Linux and Mac OS X)
Alternately, just go to the Extensions, show installed extensions, and install those on your target installation. For me, copying the extensions worked just fine, but it may be extension-specific, particularly if moving between platforms, depending on what the extension does.
There is an extension for Visual Studio Code, called Settings Sync.
It synchronises your settings by gist (Gist by GitHub). It works the same as the Atom.io extension called settings-sync.
UPDATE:
This feature is now build in VS Code, it is worth to switch to official feature.
(https://stackoverflow.com/a/64035356/2029818)
You can now sync all your settings across devices with VSCode's built-in Settings Sync. It's found under Code > Preferences > Turn on Settings Sync...
Similar to the answer given by Big Rich you can do the following:
$ code --list-extensions | xargs -L 1 echo code --install-extension
This will list out your extensions with the command to install them so you can just copy and paste the entire output into your other machine:
Example:
code --install-extension EditorConfig.EditorConfig
code --install-extension aaron-bond.better-comments
code --install-extension christian-kohler.npm-intellisense
code --install-extension christian-kohler.path-intellisense
code --install-extension CoenraadS.bracket-pair-colorizer
It is taken from the answer given here.
Note: Make sure you have added VS Code to your path beforehand. On mac you can do the following:
Launch Visual Studio Code
Open the Command Palette (⇧ + ⌘ + P) and type 'shell command' to find the
Shell Command: Install 'code' command in PATH command.
For posterity, this post mentions,
in the latest release of Visual Studio Code (May 2016) it is now possible to list
the installed extension in the command line
code --list-extensions
On Mac, execute something like:
"/Applications/Visual Studio Code.app//Contents/Resources/app/bin/code" --list-extensions
To install, use:
--install-extension <ext> //see 'code --help'
You can now synchronise all your settings across devices with Visual Studio Code's built-in Settings Sync. It's found under menu File → Preferences → Turn on Settings Sync...
Read more about it in the official documentation here.
Your user settings are in ~/Library/Application\ Support/Code/User.
If you're not concerned about synchronising and it's a one-time thing, you can just copy the files keybindings.json and settings.json to the corresponding folder on your new machine.
Your extensions are in the ~/.vscode folder. Most extensions aren't using any native bindings and they should be working properly when copied over.
You can manually reinstall those who do not.
I'm preferred my own way to synchronize all Visual Studio Code extensions between laptops, using .dotfiles and small script to perform updates automatically. This way helps me every time when I want to install all extensions I have without any single mouse activity in Visual Studio Code after installing (via Homebrew).
So I just write each new added extension to .txt file stored at my .dotfiles folder. After that I pull master branch on another laptop to get up-to-date file with all extensions.
Using the script, which Big Rich had written before, with one more change, I can totally synchronise all extensions almost automatically.
Script
cat dart-extensions.txt | xargs -L 1 code --install-extension
And also there is one more way to automate that process. Here you can add a script which looks up a Visual Studio Code extension in realtime and each time when you take a diff between the code --list-extensions command and your .txt file in .dotfiles, you can easily update your file and push it to your remote repository.
I've made a Python script for exporting Visual Studio Code settings into a single ZIP file:
https://gist.github.com/wonderbeyond/661c686b64cb0cabb77a43b49b16b26e
You can upload the ZIP file to external storage.
$ vsc-settings.py export
Exporting vsc settings:
created a temporary dump dir /tmp/tmpf88wo142
generating extensions list
copying /home/wonder/.config/Code/User/settings.json
copying /home/wonder/.config/Code/User/keybindings.json
copying /home/wonder/.config/Code/User/projects.json
copying /home/wonder/.config/Code/User/snippets
adding: snippets/ (stored 0%)
adding: snippets/go.json (deflated 56%)
adding: projects.json (deflated 67%)
adding: extensions.txt (deflated 40%)
adding: keybindings.json (deflated 81%)
adding: settings.json (deflated 59%)
VSC settings exported into /home/wonder/vsc-settings-2019-02-25-171337.zip
$ unzip -l /home/wonder/vsc-settings-2019-02-25-171337.zip
Archive: /home/wonder/vsc-settings-2019-02-25-171337.zip
Length Date Time Name
--------- ---------- ----- ----
0 2019-02-25 17:13 snippets/
942 2019-02-25 17:13 snippets/go.json
519 2019-02-25 17:13 projects.json
471 2019-02-25 17:13 extensions.txt
2429 2019-02-25 17:13 keybindings.json
2224 2019-02-25 17:13 settings.json
--------- -------
6585 6 files
PS: You may implement the vsc-settings.py import subcommand for me.
This is my syncing configuration repo for VSCodium (for Linux only). If you use VSCode, just replace the codium with code and the syncing will be fine.
https://github.com/vanvuvuong/codium_configuration
Enable Portable Mode
Portable Mode instructs Visual Studio Code to store all its configuration and plugins in a specific directory (called data/ in Windows and Linux and code-portable-data in macOS).
At any time you could copy the data directory and copy it on another installation.
VS Code provides 2 options to take care your settings. One is import/Export and other is Sync settings with github profile.
Follow below steps to Export VS code settings
Search for 'Profiles: Export' in the Command Palette (Ctrl+Shift+P).
Select 'what to export' and confirm by clicking on 'OK'
Name you export -
Select Local file which will download file
To import, choose 'Profiles: Import' from Command Palette
Often there are questions about the Java settings in Visual Studio Code. This is a big question and can involve advanced user knowledge to accomplish. But there is simple way to get the existing Java settings from Visual Studio Code and copy these setting for use on another PC. This post is using recent versions of Visual Studio Code and JDK in mid-December 2020.
There are several screen shots (below) that accompany this post which should provide enough information for the visual learners.
First things first, open Visual Studio Code and either open an existing Java folder-file or create a new Java file in Visual Studio Code. Then look at the lower right corner of Visual Studio Code (on the blue command bar). The Visual Studio Code should be displaying an icon showing the version of the Java Standard Edition (Java SE) being used. The version being on this PC today is JavaSE-15. (link 1)
Click on that icon (JAVASE-15) which then opens a new window named "java.configuration.runtimes". There should be two tabs below this name: User and Workspace. Below these tabs is a link named, "Edit in settings.json". Click on that link. (Link 2)
Two json files should then open: Default settings and settings.json. This post only focuses on the "settings.json" file.
The settings.json file shows various settings used for coding different programming languages (Python, R, and Java). Near the bottom of the settings.json file shows the settings this User uses in Visual Studio Code for programming Java.
These Java settings are the settings that can be "backed up" - meaning these settings get copied and pasted to another PC for creating a Java programming environment similar to the Java programming environment on this PC. (Link 3)
Link 1
Link 2
Link 3
For those looking for an export option for Visual Studio (not Code), use Tools menu, select "Export selected environment settings"