vscode使用wsl調試代碼


第一步在WSL中配好環境

第二步安裝CodeRunner即可,在用戶配置中加入如下行:

    "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"來設定一些終端中編譯文件的執行命令,如

"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"


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM