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 Fletcher18 Mar 2024
Resolving CVE-2022-48624 less issue
To resolve the CVE-2022-48624 vulnerability on Ubuntu using Nginx, it's crucial to understand that the issue lies within the "less" package, not Nginx itself. The vulnerability affects "less" before version 606, where close_altfile in filename.c in less omits shell_quote calls for LESSCLOSE,...