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

如何配置.vimspector.json使C++调试自动执行-enable-pretty-printing

解决方案

你之前将-enable-pretty-printing加入args不生效,是因为args字段传递的是被调试程序的启动参数,而非GDB调试器的执行命令。

正确修改方式是在配置的configuration块中新增setupCommands字段,该字段专门用于定义调试器启动完成后自动执行的预置命令,修改后的完整配置如下:

{
  "configurations": {
    "Vim - run a test": {
      "adapter": "vscode-cpptools",
      "configuration": {
        "type": "cppdbg",
        "request": "launch",
        "program": "${workspaceRoot}/main",
        "args": [],
        "cwd": "${workspaceRoot}",
        "environment": [
          { "name": "VIMRUNTIME", "value": "${workspaceRoot}" }
        ],
        "externalConsole": true,
        "stopAtEntry": true,
        "MIMode": "gdb",
        "logging": {
          "engineLogging": false
        },
        "setupCommands": [
          {
            "text": "-enable-pretty-printing",
            "description": "Enable GDB pretty printing for STL structures",
            "ignoreFailures": false
          }
        ]
      }
    }
  }
}

修改后重启调试即可自动启用STL类型的格式化打印,无需每次手动输入命令。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.09.24 10:06:04