Skip to main content

Command Palette

Search for a command to run...

How do I connect VSCode to WSL for development?

Updated
2 min read
J

I am Jyotiprakash, a deeply driven computer systems engineer, software developer, teacher, and philosopher. With a decade of professional experience, I have contributed to various cutting-edge software products in network security, mobile apps, and healthcare software at renowned companies like Oracle, Yahoo, and Epic. My academic journey has taken me to prestigious institutions such as the University of Wisconsin-Madison and BITS Pilani in India, where I consistently ranked among the top of my class.

At my core, I am a computer enthusiast with a profound interest in understanding the intricacies of computer programming. My skills are not limited to application programming in Java; I have also delved deeply into computer hardware, learning about various architectures, low-level assembly programming, Linux kernel implementation, and writing device drivers. The contributions of Linus Torvalds, Ken Thompson, and Dennis Ritchie—who revolutionized the computer industry—inspire me. I believe that real contributions to computer science are made by mastering all levels of abstraction and understanding systems inside out.

In addition to my professional pursuits, I am passionate about teaching and sharing knowledge. I have spent two years as a teaching assistant at UW Madison, where I taught complex concepts in operating systems, computer graphics, and data structures to both graduate and undergraduate students. Currently, I am an assistant professor at KIIT, Bhubaneswar, where I continue to teach computer science to undergraduate and graduate students. I am also working on writing a few free books on systems programming, as I believe in freely sharing knowledge to empower others.

To connect Visual Studio Code (VSCode) to Windows Subsystem for Linux (WSL) for development, follow these steps:

  1. Install VSCode on Windows:

    • If you haven't already, download and install Visual Studio Code from the official website.
  2. Install the Remote - WSL Extension:

    • Open VSCode.

    • Go to the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of the window or by pressing Ctrl+Shift+X.

    • Search for 'Remote - WSL' in the Extensions marketplace search bar.

    • Click on the install button for the 'Remote - WSL' extension.

  3. Open a WSL Project:

    • Once the extension is installed, you can open a WSL project in several ways:

      • From VSCode Command Palette:

        • Press Ctrl+Shift+P to open the Command Palette.

        • Type 'Remote-WSL: New Window' and press Enter. This will open a new VSCode window connected to WSL.

        • Open your project folder by going to File > Open Folder and selecting a folder within your WSL file system.

      • From Windows File Explorer:

        • Navigate to your WSL project folder using Windows File Explorer.

        • Right-click on the folder and select 'Open with Code'. This will open the folder in VSCode within the WSL context.

      • From WSL Terminal:

        • Open your WSL terminal.

        • Navigate to your project directory using cd.

        • Type code . to open the current directory in VSCode.

  4. Work on Your Project:

    • VSCode will now operate as if it's running directly on Linux. You can use the integrated terminal in VSCode to run Linux commands, and you can install extensions and tools as you would on a Linux machine.
  5. Manage WSL Instances:

    • You can switch between different WSL distributions or instances by opening the Command Palette (Ctrl+Shift+P) and typing 'Remote-WSL: New Window Using Distro...' and selecting the distribution you want to use.

By following these steps, you'll be able to develop software using VSCode on your Windows machine while taking full advantage of the Linux environment provided by WSL.

More from this blog

Jyotiprakash's Blog

251 posts

I'm Jyotiprakash, a software dev and professor at KIIT, with expertise in system programming.