Visual Studio Code (often abbreviated as VS Code) is a free, cross-platform, and open-source code editor developed by Microsoft that is available for Windows, Linux, and macOS.
The combination of a lightweight editor and powerful functionality has contributed to VS Code’s rise as one of the most popular integrated development environment (IDE) tools in recent years.
Its key features include syntax highlighting, built-in debugging support, embedded Git control, code completion, an integrated terminal, snippets, and code refactoring.
This guide will walk you through the steps for installing Visual Studio Code on your Ubuntu 22.04 system using the officially approved method.
In addition, we will also show you how to install it as a Snap package, a software distribution format recommended and enforced by Ubuntu. So, let’s get started!
Install Visual Studio Code on Ubuntu 22.04
The methods below show how to install Visual Studio Code on Ubuntu from the official Microsoft repository.
1. Install Prerequisites
Before we begin the installation, we must first install some packages that will be required to be available on our Ubuntu 22.04 system for the next steps. To accomplish this, type:
sudo apt install software-properties-common apt-transport-https wget gpg
2. Import Microsoft’s GPG Key
Next, to ensure that the packages we receive to install the Visual Studio Code are genuine, we should download and import the Microsoft signed GPG keys on our Ubuntu 22.04 system.
To do so, type the following commands:
wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg
Code language: JavaScript (javascript)
3. Add Microsoft’s Visual Studio Code Repository
After importing the GPG keys, weโll add the official Visual Studio Code repository to our Ubuntu 22.04 system. This implies that the update package will be made available with the rest of your systemโs regular updates if a new version is released.
To accomplish it, type the command shown below.
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
Code language: JavaScript (javascript)
4. Run System Update
Before we proceed with VS Code installation on our Ubuntu 22.04 system, we should update the list of available packages. So, run the below command to update the APT repositories index.
sudo apt update
As you can see, our new Microsoft Visual Studio Code repository is now available and ready to be used.
5. Install VS Code on Ubuntu 22.04
Everything is already prepared for the actual installation. Now, to install VS Code on Ubuntu 22.04, run the following commands:
sudo apt install code
6. Run Visual Studio Code on Ubuntu 22.04
You can start using VS Code by launching it from the desktop application menu. Search for “code,” and when its icon appears, click to run the same.
When you start VS Code for the first time, a window like the following should appear:
Install Visual Studio Code with Snap
Snap is an approach to distributing software encapsulated in a Snap package that offers compatibility in its use between various Linux distributions.
Since Snap is a technology developed by Canonical, the company behind Ubuntu, it is not surprising that it is attempting to force the usage of Snap packages.
However, Snap packages have some drawbacks, one being speed compared to applications installed natively from a DEB package.
The entire process of installing Visual Studio Code as a Snap package on Ubuntu 22.04 is wrapped in the execution of a single command. So if you want to install it from a Snap package, run:
sudo snap install --classic code
That’s all. The application can then be run as outlined in the previous section.
However, if you are not comfortable with the command line, you can achieve the same result by installing VS Code as a Snap package through Ubuntu’s graphical applications manager.
Run the Ubuntu Software app and search for “code,” then select it from the results list.
Next, click the “Install” button to install Visual Studio Code as a Snap package.
Conclusion
This guide showed how to install Visual Studio Code on Ubuntu 22.04 using two techniques: a native DEB application and a Snap package. Which option you choose is dependent entirely on your personal preferences.
If you have any questions, please leave them in the comments section below. To learn more about Visual Studio Code, visit their official documentation page.