How to Install Visual Studio Code on CentOS 7

Visual Studio Code is an open-source cross-platform code editor developed by Microsoft. It has a built-in debugging support, embedded Git control, syntax highlighting, code completion, integrated terminal, code refactoring and snippets.

Prerequisites

You’ll need to be logged in as a user with sudo access to be able to install packages.

Installing Visual Studio Code on CentOS

Perform the following steps to install Visual Studio Code on your CentOS system:

  1. Start by importing the Microsoft GPG key:
    sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
  2. Next, create the following repo file to enable the Visual Studio Code repository:
    sudo nano /etc/yum.repos.d/vscode.repo

    Paste the following content into the file:

    /etc/yum.repos.d/vscode.repo
    [code]
    name=Visual Studio Code
    baseurl=https://packages.microsoft.com/yumrepos/vscode
    enabled=1
    gpgcheck=1
    gpgkey=https://packages.microsoft.com/keys/microsoft.asc

    Save the file and close your text editor.

  3. Once the repository is enabled, install the latest version of Visual Studio Code by typing:
    sudo yum install code

That’s it. Visual Studio Code has been installed on your CentOS desktop and you can start using it.

Starting Visual Studio Code

Now that VS Code is installed on your CentOS system you can launch it either from the command line by typing code or by clicking on the VS Code icon (Applications -> Programming -> Visual Studio Code).

Updating Visual Studio Code

When a new version is released you can update the Visual Studio Code package through your desktop standard Software Update tool or by running the following command in your terminal:

# sudo yum update