How to Install Visual Studio Code on Ubuntu Desktop

In this article I am going to explain how easy and fast it is to install Visual Studio Code on Ubuntu, One of the most popular Linux distribution.

Install Visual Studio Code on Ubuntu Desktop

Visual Studio Code, also known as vscode is an open source text editor from Microsoft, it's been around for a while and it's getting very very popular amongst the front-end developers, so if you are front-end developer working a lot with JavaScript and other web frameworks, you definitely want to try vscode IDE.

To install Visual Studio Code on Ubuntu, we can use either gdebi package manager or vscode apt repository. We will look at both methods.

Download and Install Visual Studio Code with gdebi

The easiest and best method is to download the vscode .deb package and install it using the gdebi command. So first of all make sure you have install gdebi-core package on your Ubuntu Desktop.

sudo apt-get update
sudo apt-get install gdebi-core

Next, we need to download vs code for Ubuntu, Go to vscode download page and download the .deb package for Ubuntu 16.04.

Download Visual Studio Code for Ubuntu

Once the download is finished, Open the Ubuntu terminal, move to the download directory and execute:

sudo gdebi code_1.19.2-1515599945_amd64.deb
gdebi install vscode

And that is all you have to do to install vscode on Ubuntu Linux.

If you want to make vscode your default text editor, run following command:

xdg-mime default code.desktop text/plain

Install vscode code on Ubuntu using apt repository

It is also possible to install visual studio code on Ubuntu with apt repository by doing the following steps.

First download the gpg key using the curl command:

curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg

Move the gpg key to the /etc/apt/trusted.gpg.d directory:

sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg

Create repository file:

sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'

Then, install visual studio code with apt-get command:

sudo apt-get update
sudo apt-get install code

Manage IDE from the Command Line

The vscode IDE includes a command line tool called code which can use to manage the IDE directly from the Ubuntu terminal.

To open a new file, Execute:

code file_name

To open a folder with vscode, Type:

code dir_name

You can also use command line to add new extensions.For example, Following command will add eslint JavaScript extension to the vscode:

code --install-extension dbaeumer.vscode-eslint

To list installed extensions, Type:

code --list-extensions

VS Code is a lightweight IDE from Microsoft used for web application development and can be installed on Linux, Windows and MacOS.