文章目录
- 调试
- 常用步骤
- 技巧
- json文件变量介绍
- 快捷键
- 透明背景
- 同步配置
- 上传端
- 下载端
调试
常用步骤
- CMakeLists.txt 中的优化默认即可,后面的-O3不要,否则Debug会出现莫名其妙的跳转,
set(CMAKE_CXX_FLAGS "-std=c++11")
- 利用命令行或者cmake-tool(左下角的build,如下图)来生成可执行程序
- 点击上图右边的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"
}
]
}
- 头文件的添加
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: 图片的透明度,根据需求修改
同步配置
上传端
- 下载 setting sync
- 浏览器登录github, 创建token,创建token的时候选择gist
3. 创建完之后会得到Token的key值: 第一张图片的对勾处
4. 在vscode 快捷键: shift + alt + u ,输入key值即可,有时候跳出插件的界面,选择登录github,授权即可。便可上传配置
5. 你会得到 两串数字:token 和 Gist(id),应当保存,在其他机器下载配置需要
下载端
- 安装插件 setting sync
- 重启,快捷键 shift + alt + d
- 按提示输入上面的 token 和 id ,等待即可。