VScode技巧

调试

常用步骤

  1. CMakeLists.txt 中的优化默认即可,后面的-O3不要,否则Debug会出现莫名其妙的跳转,set(CMAKE_CXX_FLAGS "-std=c++11")
  2. 利用命令行或者cmake-tool(左下角的build,如下图)来生成可执行程序
    在这里插入图片描述
  3. 点击上图右边的Debug好像没办法传递参数,智能靠launch.json(F5),编写launch.json如下:
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "g++ build debug active file",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build/mono",    //你程序名,绝对路径,
            "args": ["${workspaceFolder}/test_data"],   // 传递的参数
            "stopAtEntry": false,
            "cwd": "${workspaceFolder}",
            "environment": [],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "mono",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}
  1. 头文件的添加
    Ctr+Shift+p选择我选中的那一行
    在这里插入图片描述
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [ //这里添加头文件
                "${workspaceFolder}/include",
                "/usr/include/eigen3/",
              
            ],
            "defines": [], // 宏定义
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "clang-x64"
        }
    ],
    "version": 4
}

技巧

  • 条件断点
    在断电上右键选择Edit Breakpoint,Expression:表达式正确就停止,Hit: ,Log Message: 编辑完之后按Enter键生效

json文件变量介绍

变量含义
${workspaceFolder}当前工作空间Folder的路径(.vscode上一级)
${file}当前打开正在编辑的文件名,包括绝对路径,文件名,文件后缀名


快捷键

快捷键功能
右键格式化整个文档
右键格式化选中
在光标处:ctr+左键自动跳转到函数
左侧的按钮(不知道叫什么名)回到跳转前的位置


透明背景

  • setting 搜:window.titleBarStyle,改成 custom
  • 修改workbench.main.css( liunx: /usr/share/code/resources/app/out/vs/workbench),其他系统(help->Toggle Developer tools),如下图,鼠标放到workbench.main.css,右键可复制路径
    在这里插入图片描述
  • 在workbench.main.css文件中追加:url 注意改成自己图片的路径
/*background start*/

body{pointer-events:auto !important;background-size:100% !important;opacity: 0.73 !important;background-position: 0 0 !important;background-image: url('/home/julian/Pictures/shuchang.jpg') !important;content:'';position:absolute;z-index:99999;width:100%;background-repeat:no-repeat;}

/*background end*/

opacity: 图片的透明度,根据需求修改


同步配置

参考1
参考2

上传端

  1. 下载 setting sync
  2. 浏览器登录github, 创建token,创建token的时候选择gist

在这里插入图片描述在这里插入图片描述
3. 创建完之后会得到Token的key值: 第一张图片的对勾处
4. 在vscode 快捷键: shift + alt + u ,输入key值即可,有时候跳出插件的界面,选择登录github,授权即可。便可上传配置
5. 你会得到 两串数字:token 和 Gist(id),应当保存,在其他机器下载配置需要

在这里插入图片描述


下载端

  1. 安装插件 setting sync
  2. 重启,快捷键 shift + alt + d
  3. 按提示输入上面的 token 和 id ,等待即可。

在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值