How do I use VS Code with WSL (Windows Subsystem for Linux)?
Jun 29, 2025 am 12:32 AMVS Code and WSL can achieve a Linux development experience on Windows. 1. First make sure that the system supports and installs WSL, run wsl --install to install the default distribution; 2. Create an account and choose to install distributions such as Ubuntu, Debian or Kali; 3. Install VS Code and add the "Remote - WSL" plug-in; 4. Open the WSL environment through the command panel, edit files and run debugging based on the Linux toolchain; 5. Note that the path is in Linux format, the project is stored in the WSL directory, the synchronization editor settings, and adapt to the debug configuration file. As long as the initial setup is correct, you can use the Linux development environment on Windows efficiently.
If you are used to the Windows desktop environment but want to use the Linux development toolchain, then VS Code with WSL (Windows Subsystem for Linux) is a very practical combination. It allows you to write code on Windows, but you can use a real Linux environment to run, debug and build projects.
Installation basic environment
First of all, you have to make sure your system supports WSL and install relevant components.
- If WSL is not installed, you can run
wsl --install
in PowerShell to enable and install the default Linux distribution (usually Ubuntu). - After the installation is complete, you will be booted to create a user account and password, and then you can use Linux commands on the command line.
- It is recommended to install a distribution you like, such as Ubuntu, Debian or Kali, which can be downloaded and installed through the Microsoft Store.
VS Code itself also needs to install the official plugin "Remote - WSL", which is the key to connecting to WSL. After installation, restart VS Code and you can use it.
Open a WSL environment in VS Code
After installing the plug-in, you can enter the WSL environment by:
- Open VS Code, press
Ctrl Shift P
to bring up the command panel; - Enter "Remote-WSL: New Window" or "Remote-WSL: Reopen Folder in WSL" and select the directory you want to operate;
- Wait for a few seconds, VS Code will automatically connect to WSL and display the file structure in the current Linux environment.
You will find that the status bar in the lower left corner turns green and displays a prompt like "WSL: Ubuntu", indicating that you are already working in the WSL environment.
In this environment, running terminals, debugging programs, and using Git are all based on Linux, and the compilation tool chain also directly calls the version in WSL.
Tips on development experience
- Note : When accessing Windows file system in WSL, the path is
/mnt/c/...
, otherwise it is not well compatible. It is recommended to place the project in the WSL home directory to avoid permission and performance issues. - Editor Font and Theme Unification : If you are used to customizing the appearance of VS Code, remember to synchronize the settings in WSL mode, otherwise you may see the default theme, which will affect the user experience.
- Debugging configuration needs to be adapted : If you are debugging a C/C program, it is best to use Linux format for the paths in the launch.json and tasks.json files, otherwise the executable file will not be found.
Another small detail is that for the first time, VS Code will automatically download the corresponding server components to the Linux environment in WSL mode, and may have to wait for a while.
Not complicated but easy to ignore
In general, the process of VS Code combined with WSL is not complicated, but if you are not careful in some places, it will affect efficiency, such as path processing, plug-in installation, debugging and configuration. Just set these up at the beginning and you can enjoy the Linux development experience on Windows smoothly.
The above is the detailed content of How do I use VS Code with WSL (Windows Subsystem for Linux)?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

The best way to make batch modifications in VSCode is to use the Find and Replace feature. 1. Use "Find and Replace" in a single file: Press Ctrl H to open the panel, enter the search and replace content, and click "Replace" or "Replace All". 2. Search across multiple files: Press Ctrl Shift F to open the search tab, expand the replacement section, and select the replacement operation for a single file or entire project. 3. Use advanced options: such as case sensitivity, full word matching and regular expressions for more precise control, such as matching numbers with \d or using capture groups for complex replacements. This feature significantly improves code maintenance efficiency through fast and precise editing.

To use VSCode for Java development, you need to install the necessary extensions, configure the JDK and set up the workspace. 1. Install JavaExtensionPack, including language support, debugging integration, build tools and code completion functions; optional JavaTestRunner or SpringBoot extension package. 2. Install at least JDK17 and verify through java-version and javac-version; set the JAVA_HOME environment variable, or switch multiple JDKs in the status bar at the bottom of VSCode. 3. After opening the project folder, make sure the project structure is correct and enable automatic saving, adjust the formatting rules, enable code checking, and configure the compilation task to optimize the opening.

TodownloadandinstallVisualStudioCode,firstchecksystemrequirements—Windows10 (64-bit),macOS10.13 ,ormodernLinuxdistributions—thenvisittheofficialwebsitetodownloadthecorrectversionforyourOS,andfollowinstallationstepsspecifictoyourplatform.Beginbyensuri

TochangeindentationsettingsinVSCode,openSettingsandtoggle"InsertSpaces"toswitchbetweentabsandspaces.1.Adjusttabsizebysearchingfor"TabSize"andsettingyourpreferredvalue.2.Configurelanguage-specificsettingsbyeditingthesettings.jsonfi

TosyncVSCodesettingsacrossdevices,signinwithaGitHuborMicrosoftaccount,customizewhatgetssynced,andmanuallytriggersyncwhenneeded.First,openVSCodeandsigninviatheprofileiconorCommandPaletteusing"Sync:TurnonSync".Next,choosewhattosyncsuchassetti

VSCode workspace is a .code-workspace file that saves project-specific configurations. 1. It supports multi-root directory, debug configuration, shortcut key settings and extension recommendations, and is suitable for managing different needs of multiple projects. 2. The main scenarios include multi-project collaboration, customized development environment and team sharing configuration. 3. The creation method is to save the configuration through the menu File>SaveWorkspaceAs.... 4. Notes include distinguishing between .code-workspace and .vscode/settings.json, using relative paths, and avoiding storing sensitive information.

To change the font size of VSCode, you can adjust, edit the JSON file, or use shortcut keys. First, enter the settings interface through "File>Preferences>Settings" (or Ctrl/Cmd,), search for FontSize and enter the numerical value to modify the font size globally; secondly, click the {} icon in the upper right corner to open the settings.json file, add "editor.fontSize": The numerical value can be precisely controlled, and you can also set the font sizes such as terminal, title, etc., such as {"terminal.integrated.fontSize":14,"title

Yes,VSCodecanautomaticallysavefiles.Toenableauto-save,gotoFile>AutoSave(Windows/Linux)orCode>AutoSave(macOS),andcheckthebox.Youcanalsosetittosaveonfocuschangebyadding"files.autoSave":"onFocusChange"tosettings.json.Formorecon
