Connect to WSL with Visual Studio Code
This guide explains how to connect to WSL (Windows Subsystem for Linux) using Visual Studio Code (VSCode).
Environment
- Windows 10 64-bit
- Visual Studio Code 1.87.2
Prerequisites
- Visual Studio Code is already installed.
Setup Flow
1. Install WSL and Ubuntu
For instructions on installing WSL and Ubuntu, please refer to this guide.
2. Install the WSL Extension for VSCode
Open Visual Studio Code and click on the Extensions icon.
In the search bar, type “wsl”, and install the extension named “WSL” from the results.
3. Open a Remote Window
Click the Remote Window icon in the bottom-left corner of VSCode.
A list of options will appear at the top of VSCode. Click “Connect to WSL”.
You will now be connected to the default WSL distribution, which is Ubuntu.
To open a folder on the Windows side while connected to WSL, click the “Open Folder” button.
Windows folders are mounted under the /mnt/
directory in Ubuntu on WSL.
For example, if the folder you want to open is on the C drive, it will be under /mnt/c/
.
Example:
After entering the folder path, click “OK” to open the folder.