vscode tips

1.设置格式化代码大括号“{”不换行

  • 文件(File)–>首选项(Preferences)–>设置(settings)
  • 搜索brace
  • C_Cpp: Clang_format_fallback Style默认为Visual Studio,改为{ BasedOnStyle: Chromium, IndentWidth: 2}
  • 第二个设置是缩进

2.配置单步调试

  • Ctrl+Shift+p,选择C/C++:Edit Configurations(JSON),主要添加头文件路径

  • Ctrl+Shift+p,选择tasks: Configure Task,根据需求修改command,args,group,presentation

    • {
      // See https://go.microsoft.com/fwlink/?LinkId=733558 
      // for the documentation about the tasks.json format
      "version": "2.0.0",
      "tasks": [
          {
              "type": "shell",
              "label": "make",
              "command": "cd build && cmake . && make",
              "args": [
              ],
              "group": {"kind":"build","isDefault":true},
              "presentation": {
                  "reveal": "always"//可选always或者silence,代表是否输出信息
              },
              "problemMatcher": "$msCompile"
          }
      ]
      }
      
      
  • 点击左侧工具栏”Debug“(小虫),点击”齿轮“按钮,此时.vscode文件夹下面就会自动生成launch.json文件,将program的值改为可执行程序的路径。同时,可以使用"preLaunchTask"选项在调试前自动编译。

  • 笔者遇到了断点无效的情况,是因为在编译的时候没有-g选项,需要在CMakeLists.txt中加入add_compile_options(-g)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

刀么克瑟拉莫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值