How to set up VS Code with WSL 2 on Windows 10/11
Microsoft's Visual Studio Code is very popular and loved by the developer community. Windows Subsystem for Linux is powerful, but if you integrate Visual Studio Code on your Windows PC with WSL's kernel, you can do a lot in less time and in a better way.
The following article will discuss WSL and how you can set up VS Code on Windows for a seamless workflow.
Why use Visual Studio Code with WSL 2?
VS Code is a powerful integrated development environment (IDE) created by Microsoft that supports all kinds of programming languages. Developers prefer to use Visual Studio Code because it works on almost any platform, including macOS, Linux, and Windows. It also has a large community dedicated to building great extensions that make development easier.
As a developer, the ability to use Visual Studio Code to develop applications on the Windows platform and run those applications on the Linux kernel is an incredibly handy feature and offers amazing benefits.
When integrating VS Code into the Windows Subsystem for Linux, you can use its specialized Linux kernel to enhance cross-platform compatibility. You can further streamline your workflow using the built-in terminal in VS Code with WSL 2.
How to integrate WSL 2 with Visual Studio Code
Although the Windows Subsystem for Linux provides a dedicated Linux kernel so you can run your applications, you cannot directly edit the code through its terminal. Fortunately, you can ease the workflow by configuring Visual Studio Code to integrate with your WSL 2 Linux distribution.
How to install Visual Studio Code
As a prerequisite, you must first make sure VS Code is set up correctly on your Windows PC. Installing VS Code is simple and straightforward, but if you're unsure, you can check out TipsMake's beginner's guide to setting up Visual Studio Code on a Windows PC:
1. Go to the following link and download the Windows installer.
2. When the download is complete, run the setup setup.
3. Click Next until you see the Select Additional Tasks step and make sure the Add to PATH option is selected.
4. Complete the installation wizard.
If you have VS Code installed, you need to make sure you can use the terminal to open a folder in VS Code:
- Launch VS Code from the Desktop or Start menu.
- Select Ctrl + Shift + P to open the Command Palette .
- In the search box, type shell command and look for the option Shell Command: Install "code" command in shell PATH .
- Select the option if you can see it. This will allow you to open a folder in Visual Studio Code from the command line.
If the option does not appear, then the VS Code profile is enabled on your PC.
How to configure VS Code with WSL 2
Once you've made sure VS Code is set up properly on your Windows PC, you can safely connect VS Code to Windows Subsystem for Linux 2:
1. You can move on to the next step if you already have WSL 2 configured on your system. If not, download Ubuntu from the Microsoft Store to get started.
2. Launch the Start menu, search for Visual Studio Code and select the best match.
3. From the side menu pane, click the Extensions icon or use the keyboard shortcut Ctrl + Shift + X to view installed extensions.
4. In the Search Extensions in Marketplace field , search for WSL , select the best match and click Install .
5. Once the extension is installed, launch your WSL 2 distribution (in the case of Ubuntu) via the Start menu. You can also open it via the new Windows Terminal.
6. Navigate to the project folder in WSL 2 with the cd command and then enter the following command to open the folder in VS Code:
code .
7. VS Code now opens your source code in a Windows environment but allows you to debug and test your application in a Linux environment.
If you are a developer who is not completely satisfied with Linux but still need to use it for work, the article really recommends getting familiar with WSL 2. It's an amazing tool that will get better and better. in the coming years.
You should read it
- Steps to initially set up a new SSD on Windows 10
- 6 best code editor apps for Mac
- What is QR code?
- The classic cheat codes, almost every 8x 9x player knows by heart
- Synthesis of useful commands to code the Arduino
- How to Program a Philips Universal Remote
- How to Set Up RCA Controls Without a Code Search Button
- Instructions for fixing device Usb error not recognized Code 43
May be interested
- Configure the 'brain damage' PIN to log on to Windows 10on windows 10 is integrated a lot of login options, users can choose, including pin code. if you're using a mobile device, you're probably familiar with pin codes, an authentication solution similar to passwords, but there are some more unique features.
- How to customize the Windows 10 PIN code limitsetting pin windows 10 is one of the methods to protect computers safely and effectively. however, the pin will be limited to a minimum of 4 characters and a maximum of 10 characters. so how to adjust the short, long for windows 10 pin code.
- What is 'Code 10' error in Windows? And how to fix it?while using the computer, you will probably get the error message '' this device cannot start. (code 10) ', also known as' code 10 error '. let's learn and refer to how to fix error 'code 10' in windows.
- How to Fix Roblox error code 523 in Windows 11/10while trying to join a roblox gaming session, you may get an error: the status of the game has changed, and you no longer have access, error code: 523.
- Use PIN to login Windows 10on windows 10, microsoft has provided users with a lot of login options such as traditional login options - using passwords, pin codes, face recognition, using fingerprints. if you are using the latest version of windows 10, you can set up a pin to log in. logging in with pin is one of the most useful security solutions on windows 10.
- Instructions for creating pin code in Windows 10setting pin for windows 10 will shorten the password login operation that you usually do, but security is still guaranteed.
- What is QR code?qr codes have become increasingly popular, becoming a tool for logging into websites, wifi networks, sharing information, electronic payment, data storage or electronic tickets ...
- How to fix error code 0x8007139f on Windows 10/11if you are a windows 10 or windows 11 user, you may have seen error code 0x8007139f. you can now see this error code for windows update, mail app, microsoft account, windows defender, when activating windows, playing xbox games, or using a pin.
- How to Run HTML Files on Visual Studio Codevisual studio code is microsoft's source code editor. the program is currently available for windows, macos, and linux. with visual studio code, you'll be able to write and edit code in many different programming languages, including html. but what do you do when you want to implement some html code? luckily, there are many extensions for visual studio code that make it easy to execute html code right in visual studio code. additionally, you can also use terminal to run html files. today's tipsmake will show you how to run html files on visual studio code.
- The classic cheat codes, almost every 8x 9x player knows by heartcheat code, also known as cheat code, is the code, the statement ... added by the manufacturer to change some game features and help players 'clearing' easier.