You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在VS Code中默认使用Windows Terminal运行程序

VS Code CodeRunner调用Windows Terminal运行C++程序配置步骤

步骤1:配置VS Code默认外部终端为Windows Terminal

  • 按下Ctrl + ,快捷键打开VS Code设置页面
  • 在顶部搜索框输入terminal.external.windowsExec,找到「Terminal > External: Windows Exec」配置项
  • 输入Windows Terminal的可执行文件路径,默认安装路径为C:\Users\你的系统用户名\AppData\Local\Microsoft\WindowsApps\wt.exe,若自定义了安装位置,替换为实际的wt.exe路径即可

步骤2:修改CodeRunner运行终端配置

  • 同样在设置页面搜索code-runner.runInExternalTerminal,找到「Code-runner: Run In External Terminal」选项,勾选该选项
  • (可选)如果需要自定义C编译参数,搜索code-runner.executorMap,点击「在settings.json中编辑」,找到cpp对应的配置行,按需修改编译指令,比如添加C标准参数:
"code-runner.executorMap": {
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++17 && $dir$fileNameWithoutExt",
}
  • (可选)如果需要运行结束后终端不自动关闭,可在上述cpp指令末尾添加 & pause,修改后为:
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt -std=c++17 && $dir$fileNameWithoutExt & pause"

步骤3:验证配置

  • 打开任意C++代码文件,按下CodeRunner运行快捷键Ctrl + Alt + N,即可看到Windows Terminal自动弹出并完成编译、运行操作

内容的提问来源于stack exchange,提问作者Rahul Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.03 10:48:02