Installing vscode extensions from within the Visual Studio Code terminal was way easier than I anticipated
Posted by jpluimers on 2022/11/09
Having missed quite a lot of Visual Studio Code releases during my metastasised rectum cancer treatment and recovery, it had become both very mature, but also very reliant of having the right extensions installed.
In that period, the extension marketplace grew remarkably, so I really wanted an easy way to install them from within the inside vscode
integrated Windows Terminal.
A while ago I wrote How can you export the Visual Studio Code extension list? (via: Stack Overflow), which generated a small script with code --install-extension <extension-name>
lines so I could executed those from the command-line for Visual Studio installations on new machines.
Boy was I surprised that you can just as well execute them from the [Wayback/Archive] Integrated Terminal in Visual Studio Code as well (:
When doing so, the Visual Studio Code instance around that Integrated Terminal will automatically pick up the new extension.
I found that with a [Wayback/Archive] vscode install extension from within visual studio code console – Google Search and bumping in the video also embedded below the signature: [Archive] VS Code tips — Installing extensions from the command line using –install-extension – YouTube.
The video also showed that the installation syntax can also include the version number like this:
code --install-extension DavidAnson.vscode-markdownlint@0.44.4
So I in addition to a batch script that dumps all installed extensions from my blog post above:
@for /f %%l in ('code --list-extensions') do @echo code --install-extension %%l
I also made one that includes the version numbers:
@for /f %%l in ('code --list-extensions --show-versions') do @echo code --install-extension %%l
It produces output like the above installation line including @
sign and version number.
Finally I learned a few things from [Wayback/Archive] cmd – How to install Visual Studio Code extensions from Command line – Stack Overflow.
First [Wayback/Archive] Shan Khan taught me how to uninstall:
To make it easier to automate and configure VS Code, it is possible to list, install, and uninstall extensions from the command line. When identifying an extension, provide the full name of the form publisher.extension, for example donjayamanne.python.code --list-extensions code --install-extension ms-vscode.cpptools code --uninstall-extension ms-vscode.csharp
then [Wayback/Archive] Peterino to upgrade without questions asked:
Updating an extension is now possible using the
--force
option with--install-extension
. (See GitHub issue [Wayback/A] #58434, commit [Wayback/Archive] 1dd7326)
and [Wayback/Archive] User Wade Anderson that you can also install from a local .vsix
installation file:
You can manually install an VS Code extension packaged in a .vsix file. Simply install using the VS Code command line providing the path to the .vsix file.code --install-extension myExtensionFolder\myExtension.vsix
The extension will be installed under your user .vscode/extensions folder. You may provide multiple .vsix files on the command line to install multiple extensions at once.
Further reading
Some more links from the above Google search:
- [Wayback/Archive] Managing Extensions in Visual Studio Code: Command-line extension management
- [Wayback/Archive] vscode install extension in terminal Code Example
- [Wayback/Archive] Install extension – vscode-docs
- Your extensions folder
- Sharing privately with others (side-loading)
- Installing a packages extension (.vsix)
- Publishing to the gallery
–jeroen
Leave a Reply