vscode使用wsl调试代码

第一步在WSL中配好环境c++

第二步安装CodeRunner便可,在用户配置中加入以下行:shell

"terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\bash.exe",//设置内置终端为WSL
    "code-runner.runInTerminal": true,//使用内置终端
    "code-runner.saveFileBeforeRun": true,//运行前保存
    "code-runner.clearPreviousOutput": true,//运行前清理旧的输出文件
    "code-runner.ignoreSelection": true,//忽略用户选择
    "code-runner.preserveFocus": false,//运行时焦点跳回编辑器

以后,只要在WSL装好能正确运行的环境就能够了。能够经过改变"code-runner.executorMap"来设定一些终端中编译文件的执行命令,如windows

"c": "cd $dirWithoutTrailingSlash && gcc $fileName -o $fileNameWithoutExt -std=c11 -lm && echo '[Running]' && ./$fileNameWithoutExt",
"cpp": "cd $dirWithoutTrailingSlash && g++ -Wall $fileName -o $fileNameWithoutExt -std=c++11 -lm && echo '[Running]' && ./$fileNameWithoutExt"
相关文章
相关标签/搜索