How To Install Visual Studio Code On WSL

Introduction

In this article, you will learn how we can install Visual Studio Code on WSL2. 

To learn to install WSL2 on Windows 11, visit.

Visual Studio Code

Microsoft's Visual Studio Code is a source code editor available for Windows, Linux, and macOS. Support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and integrated Git are among the features. Users may customize the theme, keyboard shortcuts, and preferences, as well as install extensions that offer further functionality.

Install VS Code on WSL2

There are separate ways to install VS Code on different Linux distributions. Currently, we can install the following distros on WSL

  • Ubuntu
  • Debian GNU/Linux
  • Kali
  • openSUSE Leap 42
  • SUSE Linux Enterprise Server 12 (SLES)

1. Install VSCode on Ubuntu or Debian GNU/Linux or Kali

We have a common command mechanism to install VS Code on Ubuntu, Debian, and Kali based distributions.

wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg
sudo install -o root -g root -m 644 packages.microsoft.gpg /etc/apt/trusted.gpg.d/
sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/trusted.gpg.d/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list'
rm -f packages.microsoft.gpg

Note: If wget is not installed, please install it using the command

sudo apt-get install wget

After that execute the following command, to install the VS code

sudo apt install apt-transport-https
sudo apt update
sudo apt install code # or code-insiders

2. Install VSCode on openSUSE or SLES

We have a common command mechanism to install VS Code on openSUSE and SLES.

sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/zypp/repos.d/vscode.repo'

After that execute the following command to install the VS Code

sudo zypper refresh
sudo zypper install code

After Installation

Once you are done installing, you will get VS Code app listed on your Windows machine. Click the VS Code app for WSL, to launch the application.

Conclusion

In this article, we discussed how one can install VS Code on WSL.

To learn about basic Linux commands, visit.



C# Corner
MVP Program Director