How to Install Visual Studio Code on Ubuntu 22.04

The Visual Studio Code, referred to as VS Code, is introduced by Microsoft for various operating systems, including Linux. It is a source-code editor that helps in writing, editing, and debugging the codes in several languages efficiently.

The Visual Studio Code introduces advanced key features such as snippets, syntax highlighting, code refactoring, and many more. This write-up will enhance your knowledge of installing the Visual Studio Code on Ubuntu 22.04. The outcomes of this blog would be:

Let’s start with the first one:

Method 1: Install Visual Studio Code on Ubuntu 22.04 Using its Repository

Ubuntu does not come with the Visual Studio (VS) Code with its default repository. However, it can be installed on system Ubuntu 22.04 using the GPG key of VS Code. To fulfill this aim, obey the below-mentioned procedure:

Step 1: Update System Packages

For updating the core packages of the system, execute the below script:

$ sudo apt update

The repository of system packages is updated.

Step 2: Import the GPG Key

The GPG key ensures safe communication over the insecure connection. To add the GPG key of VS Code, execute the below script:

$ curl -sSL https://packages.microsoft.com/keys/microsoft.asc | sudo gpg --dearmor -o /usr/share/keyrings/ms-vscode-keyring.gpg

The GPG key is added successfully.

Step 3: Add Visual Studio Code Repository

For adding the repository of Visual Studio Code into existing system, execute the below script:

$ echo "deb [arch=amd64 signed-by=/usr/share/keyrings/ms-vscode-keyring.gpg] https://packages.microsoft.com/repos/vscode stable main" | sudo tee /etc/apt/sources.list.d/vscode.list

The repository of VS Code was added successfully.

Step 4: Updating Packages of the System

After importing the VS Code repository and GPG key, you must update the system packages by running the following command:

$ sudo apt update

The system packages are upgraded.

Step 5: Install VS Code Editor

Now, to install the VS Code editor, run the following command:

$ sudo apt install code

The script was executed on Ubuntu 22.04.

How to Launch Visual Studio Code on Ubuntu 22.04?

After successfully installing VS Code on Ubuntu 22.04, you can launch it using the Graphical User Interface. For this, click on the “Activity” and write the “Visual Studio” in the search bar as follows:

Click on Visual Studio launcher. It will launch the Visual Studio Code. You can choose the theme you want:

After choosing your favorite theme, the following interface will open:

The VS Code is now ready to use. Here you can select a new file, open the existing file, or even a folder.

How to Remove Visual Studio Code From Ubuntu 22.04?

If the user has installed the Visual Studio (VS) code on Ubuntu 22.04 using the apt package manager, the user can remove it with the below script:

$ sudo apt remove code

The Visual Studio (VS) Code has been successfully removed from Ubuntu 22.04.

Method 2: Install Visual Studio Code on Ubuntu 22.04 Using Snap

Snap is a complete software package used to install the application on Ubuntu 22.04. The Visual Studio (VS) Code can be installed on Ubuntu using snap. To fulfill this purpose, run the following command:

$ sudo snap install code --classic

The Visual Studio (VS) code is now installed on Ubuntu 22.04.

How to uninstall Visual Studio Code from Ubuntu 22.04 via Snap

For the installed Visual Studio (VS) Code from Snap, users can uninstall VS  by the below script:

$ sudo snap remove code

The Code (VS Code) is removed successfully from Ubuntu 22.04.

Well Done! Users have experienced the different methods for installing the Visual Studio (VS) Code on Ubuntu 22.04.

Conclusion

The Visual Studio (VS) code can be installed on Ubuntu 22.04 via the apt package manager “sudo apt install code” after adding the PPA repository. Moreover, it can also be installed from the snap store using the “sudo snap install code –classic” command. This post has provided detailed installation methods of VS code on Ubuntu 22.04.