Skip to main content

Visual Studio Code (VS Code) allows you to manage extensions using the VS Code Command Line Interface (CLI) called code. With the code CLI, you can install, list, uninstall, and manage extensions from the command line.  

To check you have the code prompt running, run

code --version

Response you're looking for is

1.83.0
d3a019177ff8833cf320e334265dfea540098a3a
arm64

If not, to install, in VS Code press command + shift + p to open the command palette, then type "install code", click Shell command: Install 'code' command in PATH.  In terminal, type code YOUR_FILENAME` to open that file in VS Code.

Common commands for managing extensions using the code CLI:

Install an Extension

To install an extension from the command line, use the --install-extension flag followed by the extension's unique identifier. For example:

code --install-extension publisher.extension-name

Replace publisher.extension-name with the actual identifier of the extension you want to install.

List Installed Extensions

To list all the installed extensions, use the --list-extensions flag:

code --list-extensions

This command will display a list of installed extensions.

Uninstall an Extension

To uninstall an extension, use the --uninstall-extension flag followed by the extension's unique identifier:

code --uninstall-extension publisher.extension-name

Replace publisher.extension-name with the identifier of the extension you want to uninstall.

Update Extensions

You can use the --force flag with the --install-extension flag to force the update of an extension to the latest version. For example:

code --install-extension publisher.extension-name --force

This will update the specified extension to the latest available version.

Install Extensions from a List

You can also install multiple extensions listed in a text file. Create a text file that contains a list of extension identifiers, one per line. Then, use the --install-extension flag with the --force option to install them. For example:

cat extensions.txt | xargs -L 1 code --install-extension --force

This will install all the extensions listed in the extensions.txt file.  Remember that the code CLI needs to be in your system's PATH for these commands to work. Additionally, you can automate extension management by scripting these commands if you have a specific set of extensions to manage across multiple installations of VS Code.

Related articles

Andrew Fletcher16 Jul 2024
How to efficiently use find and replace in VS Code
When it comes to text editing, Visual Studio Code (VS Code) is one of the most popular tools among developers. One of its powerful features is the Find and Replace function, which can save you countless hours of manual editing. In this article, we'll explore how to use this function to replace all...
Andrew Fletcher20 May 2024
Create a copy of files that go to the tmp directory
To review the content of files being generated in the /tmp directory on an Ubuntu server before Microsoft Defender removes them, you can use several approaches.  Following is the approach we took. Real-Time MonitoringYou can set up a script to monitor the /tmp directory and log the...