安装插件

Remote WSL
C/C++
CMake Tools
SVN
Clang-Format

Ubuntu安装SVN客户端

apt-get install subversion

启动远程

点击左下角->打开远程窗口->Remote WSL: New Windows->点击打开文件夹->指定路径

调试

点击调试->创建launch.json

{
    // 使用 IntelliSense 了解相关属性。 
    // 悬停以查看现有属性的描述。
    // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) 启动",
            "type": "cppdbg",
            "request": "launch",
            "program": "${command:cmake.launchTargetPath}",
            "args": [],
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}/bin",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        }
    ]
}

调试出错

提示#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (/build/glibc-xxxx/glibc-2.27....
xxxx代表具体的某个名字 出错时候注意下就行了

sudo mkdir -p /build/glibc-xxxx
cd /build/glibc-xxxx
sudo wget http://ftp.gnu.org/gnu/glibc/glibc-2.27.tar.gz
sudo tar –zxvf glibc-2.27.tar.gz

vim快捷键冲突

文件->首选项->设置->在settings.json中编辑

{
    "C_Cpp.updateChannel": "Insiders",
    "cmake.configureOnOpen": true,
    "[cpp]": {
        "editor.defaultFormatter": "xaver.clang-format"
    },
    "vim.handleKeys": {
        "<C-a>": false,
        "<C-c>": false,
        "<C-x>": false,
        "<C-f>": false,
        "<C-h>": false,
        "<C-s>": false,
        "<C-z>": false,
        "<C-y>": false,
    },
}

如果遇到VS连接WSL错误

删除当前用户下的.vscode-server文件夹重新连接即可