How to use VSCode on WSL

How to use VSCode on WSL

The Windows Subsystem for Linux (  WSL ) is one of the useful tools you should always have in your repertoire. And if you use Visual Studio Code for your programming projects, there is a way to use it without having to open a new command prompt.

Why Use VSCode and WSL

If you are a developer, programmer, or computer science student, you have probably encountered compatibility issues between devices and operating systems.

In fact, even a simple plain text editor won't work on a different operating system if it wasn't built with cross-compatibility in mind. That's why you need to test and develop in different software environments - and that's exactly what WSL does best.

But here’s the problem. Running GUI applications on WSL can get very slow. And Visual Studio Code, as good as it is with all its features, isn’t exactly friendly to slow machines. Worse if you’re using it to build Linux GUI software.

This is where the Visual Studio Code WSL extension comes in. It runs on your Windows version of Visual Studio Code but programs things in the WSL file system.

How does the Visual Studio Code WSL extension work?

The WSL extension for Visual Studio Code allows you to access your WSL files remotely. It's similar to doing things with SSH. You're not directly using the resources of your WSL installation to run Visual Studio Code, but it's editing your WSL files while using regular Windows resources.

Not only does this free up processing power to run GUI application prototypes, but it also gives you a new environment for development.

However, this means that some extensions that rely on third-party software will not work unless you install them in your WSL environment as well. So no compilers, no Docker, no Node, and definitely no interpreters. Even PlatformIO won’t work.

As it is, using the WSL extension has its pros and cons. But if the other alternative is to run a Linux distribution on USB or dual boot, the benefits of using WSL speak for themselves.

How to connect VSCode to WSL

  • In Visual Studio Code, go to Extensions and search for “WSL” in the Extensions search bar.


  • Click the "Install" button. Wait for it to finish.


  • Launch the command search bar by going to Help -> Show All Commands or pressing CTRL+Shift+P.


  • Type WSL: Connect to WSL in the command search bar to connect to WSL.

Note: WSL calls this "Starting a Remote Connection" and you'll know it's connected if WSL: <your distro> appears in the lower left corner.

  • On the first run, the extension will search for the WSL currently installed on your computer. If it is not available or the extension cannot find it, you will have to download it first using the command "Connect to WSL using Distro…".

How to Install Extensions on WSL Visual Studio Code

  1. Click the Extensions button to see a list of Visual Studio Code extensions. There should be a new category that says “Local - Installed”.
  2. For the add-ons you need, you can click the button that says "Install on WSL: <your distro>" to make them easier to access in your current distribution.


  • Once installed, you can continue using it even if you disconnect from your  WSL distribution and reconnect at a later time. You are now ready to use Visual Studio Code on WSL.

google-playkhamsatmostaqltradent