Andrew
Andrew

Reputation: 7468

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.

Upvotes: 697

Views: 398402

Answers (29)

Tobi
Tobi

Reputation: 11

If you need help to download all your extensions for manual install in Cursor:

Powershell:

code --list-extensions | % { Start-Process "https://marketplace.visualstudio.com/items?itemName=$_" }

Maybe this can help a bit, it opens all the Marketplace websites of the listed addons where you just have to click "Download Extension".

Upvotes: 1

sparrowt
sparrowt

Reputation: 2988

The other answers require a working 'source' machine, however if you only have the files from it (e.g. a disk extracted from a device with other failed hardware) then you can recover & reinstall the extensions like this:

  1. Find the file path/to/old/userhome/.vscode/extensions/extensions.json (help) from the old disk & copy this file to the target machine where you want to reinstall all these extensions.

  2. On the new machine, run this in PowerShell:

    cd <the folder where you copied extensions.json>
    (Get-Content extensions.json | ConvertFrom-Json).ForEach({ Write-Host $_.identifier.id }) | % { code --install-extension $_}
    
  3. Job done!

Upvotes: 2

sharhp
sharhp

Reputation: 418

This method uses helps install existing extensions on a new system (with reference to an existing system) using .vsix package

It requires Yeoman VS Code extension generator and vsce (or nodejs to install these).

  1. 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)

enter image description here

enter image description here

enter image description here

  1. 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)

enter image description here

  1. On the new system, install the .vsix file
code --install-extension extension-pack-0.0.1.vsix
  1. Open VS Code on the new system, access this extension, install all required extensions via GUI

enter image description here

PS: If you are going to publish the extension pack then consider filling in all details appropriately, while creating it.

Upvotes: 0

Falieson
Falieson

Reputation: 2556

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

For Windows:

On the old machine:

code --list-extensions > vscode-extensions.list

On the new machine:

Get-Content vscode-extensions.list | ForEach-Object { code --install-extension $_ }

Upvotes: 47

Wenfang Du
Wenfang Du

Reputation: 11407

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.bash

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.bash'

Install extensions

. install-extensions.bash

Upvotes: 25

Benson
Benson

Reputation: 4401

How to share VS Code extensions without using plugins, gists, sharing files or forcing users to use a multi-line command

If you need to send all your extensions to install on another computer, 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

How to create the single-line command:

1. In your terminal, run the following command:

code --list-extensions

2. Copy your list of extensions from the terminal and paste your copied list into a new document. Do a regex search and replace in VS Code to share extensions on new computer

3. Open a Search and Replace prompt (CTRL+R on Windows) and do a REGEX search for:

(.+)(\n?)

4. Replace with

 --install-extension $1

(Don't omit the space at the beginning.)

5. Add the word code to the beginning 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 ...

Upvotes: 7

John Bentley
John Bentley

Reputation: 1834

On Windows using PowerShell script, including a 'friendlyName' which better matches the extension name as it appears in Visual Studio Code interface (which code --list-extensions doesn't do):

<#
.SYNOPSIS
    Gets installed Visual Studio Code extensions in a friendly format.

.DESCRIPTION
    Gets installed Visual Studio Code extensions in a friendly format.

.INPUTS
    None. You cannot pipe objects to this.

.OUTPUTS
    Installed Visual Studio Code extensions in a friendly format.

.EXAMPLE
    PS> .\Get-VSCodeExtensions.ps1

.NOTES
    Authors: John Bentley, Andrew D. Bond <https://github.com/andrewdbond/>

    Updated: 2023-03-22

    Latest:
    How can you export the Visual Studio Code extension list?: https://stackoverflow.com/a/72929878/872154
#>

$extensions = (Get-Item $HOME/.vscode/extensions/*/package.json).ForEach({
    Get-Content $_ | ConvertFrom-Json | Select-Object `
        @{name='friendlyName';expr={if($_.PSObject.Properties['displayName']) {$_.displayName} else { $_.name}}},
        @{name='publisherAndName';expr={"$($_.publisher).$($_.name)"}},
        description,
        homepage,
        @{name='repository.url';expr={$_.repository.url}},
        version
}) | Sort-Object friendlyName

Write-Output $extensions
# Optional: Set clipboard with the results to paste into Google Sheets, Excel, etc.
$extensions | ConvertTo-Csv | Set-Clipboard

Example output:

friendlyName     : Pylance
publisherAndName : ms-python.vscode-pylance
description      : A performant, feature-rich language server for Python in VS Code
homepage         : 
repository.url   : https://github.com/microsoft/pylance-release
version          : 2023.3.20

friendlyName     : Python
publisherAndName : ms-python.python
description      : IntelliSense (Pylance), Linting, Debugging (multi-threaded, remote), Jupyter Notebooks, code formatting,  
                   refactoring, unit tests, and more.
homepage         : https://github.com/Microsoft/vscode-python
repository.url   : https://github.com/Microsoft/vscode-python
version          : 2023.4.1

Instructions (Windows only):

  1. Paste the above script code into a PowerShell terminal

Or

  1. Copy the above script code and save it somewhere as Get-VSCodeExtensions.ps1
  2. Open a PowerShell terminal at the directory where you saved Get-VSCodeExtensions.ps1 (cd might help here)
  3. Run the script from the PowerShell terminal with .\Get-VSCodeExtensions.ps1

Upvotes: 2

pgfearo
pgfearo

Reputation: 2256

Use Visual Studio Code's Profiles feature (introduced February 2023) to share settings, including installed extensions, with colleagues using a named Profile.

From VS Code:

  1. Invoke the command: Profiles: Export Profile
  2. In the Profiles view, review the Settings, UI State and Extensions:

enter image description here

  1. From the Profiles view, click the Export button
  2. Enter a name for the profile - if prompted
  3. Select the GitHub gist save option
  4. Once saved, you will see the following:

enter image description here

  1. Press the Copy Link button to save the URL

In the Browser:

  1. Visit the GitHub gist site where you should see a new Gist with your profile name:
  2. Select the new Gist and click the 'Edit' button
  3. In edit-mode, press the 'Make Public' button

Share and Import:

  1. Share the URL you copied earlier with colleagues who can use the Profiles: Import Profile command.
  2. The imported Profiles is associated with the current workspaces.
  3. Profiles can later be switched, renamed etc. from within VS Code

Upvotes: 17

SridharKritha
SridharKritha

Reputation: 9681

File > Preferences > Turn on Settings Sync Will sync your VS Code settings across different devices.

I'm using VS Code Version 1.74.0

Upvotes: 1

Gustavo de Lima
Gustavo de Lima

Reputation: 63

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.

Upvotes: 5

garlicbread
garlicbread

Reputation: 361

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\

Upvotes: 3

nPcomp
nPcomp

Reputation: 9973

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

Upvotes: 1

user7023735
user7023735

Reputation:

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.

  1. Export your extensions to a shell file:
code --list-extensions | sed -e 's/^/code --install-extension /' > my_vscode_extensions.sh
  1. 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

Upvotes: 7

Morten
Morten

Reputation: 2328

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 $_}

Upvotes: 17

codescope
codescope

Reputation: 293

  1. code --list-extensions > list

  2. sed -i 's/.*/\"&\",/' list

  3. Copy contents of file list and add to file .vscode/extensions.json in the "recommendations" section.

  4. If extensions.json doesn't exist then create a file with the following contents

    {
        "recommendations": [
            // Add content of file list here
        ]
    }
    
  5. Share the extensions.json file and ask another user to add to the .vscode folder. Visual Studio Code will prompt for installation of extensions.

Upvotes: 4

godblessstrawberry
godblessstrawberry

Reputation: 5068

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"
    ]
}

Upvotes: 16

eziegl
eziegl

Reputation: 351

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.

Upvotes: 3

&#193;lvaro Gonz&#225;lez
&#193;lvaro Gonz&#225;lez

Reputation: 146588

Benny's answer on Windows with the Linux subsystem:

code --list-extensions | wsl xargs -L 1 echo code --install-extension

Upvotes: 4

milanio
milanio

Reputation: 4232

Windows (PowerShell) version of Benny's answer

Machine A:

In the Visual Studio Code PowerShell terminal:

code --list-extensions > extensions.list

Machine B:

  1. Copy extension.list to the machine B

  2. In the Visual Studio Code PowerShell terminal:

     cat extensions.list |% { code --install-extension $_}
    

Upvotes: 81

esthor
esthor

Reputation: 412

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

Upvotes: 2

Vlad
Vlad

Reputation: 837

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

Upvotes: 0

MUG4N
MUG4N

Reputation: 19717

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.

Upvotes: 31

Damien Leroux
Damien Leroux

Reputation: 11693

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.

Upvotes: 9

sadisaks
sadisaks

Reputation: 121

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

Upvotes: 12

Shan Khan
Shan Khan

Reputation: 10339

I have developed an extension which will synchronise your all Visual Studio Code settings across multiple instances.

Key Features

  1. Use your GitHub account token.
  2. Easy to upload and download on one click.
  3. Saves all settings and snippets files.
  4. Upload key: Shift + Alt + U
  5. Download key: Shift + Alt + D
  6. Type Sync In Order to View all sync options

It synchronises the

  1. Settings file
  2. Keybinding file
  3. Launch file
  4. Snippets folder
  5. Visual Studio Code extensions

Detail Documentation Source

Visual Studio Code Sync ReadMe

Download here: Visual Studio Code Settings Sync

Upvotes: 63

Juri
Juri

Reputation: 32920

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.

Upvotes: 3

MarkP
MarkP

Reputation: 4985

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

Upvotes: 284

Benny Ng
Benny Ng

Reputation: 12486

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

  1. Export of your configuration and extensions
  2. Share it with coworkers and teams. You can update the configuration. Their settings will auto updated.

Manual

  1. 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.

  2. 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 $_" }
    
  3. 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).

Upvotes: 1111

Michael_Scharf
Michael_Scharf

Reputation: 34548

There is an Extension Manager extension, that may help. It seems to allow to install a set of extensions specified in the settings.json.

Upvotes: 4

Related Questions