文章目录
1、文档
2、技巧
显示与搜索
VS Code 支持以下 glob 语法:
/
分隔路径段*
匹配路径段中的零个或多个字符?
匹配路径段中的一个字符**
匹配任意数量的路径段,包括无{}
对条件进行分组(例如 {**/*.html,**/*.txt} 匹配所有 HTML 和文本文件)[]
声明要匹配的字符范围(example.[0-9] 匹配 example.0,example.1 … )[!...]
否定要匹配的字符范围(example.[!0-9] 匹配 example.a、example.b,但不匹配 example.0 )
注意:在 Windows 上使用的是 /
来分隔路径而不是 \
。VS Code 中的 Glob 模式需要 /
分隔路径,但它们都会在路径上 /
和 \
路径内匹配。
.vscode/settings.json
中 files.exclude
控制文件显示,search.exclude
控制搜索 。
{
"files.exclude": {
"**/*.a.cmd": true,
"**/*.order.cmd": true,
"**/*.o.cmd": true,
"**/*.o.d": true,
// "**/*.o": true,
".github": true,
"arch/[^a]*": true,
"arch/a[^r]*": true,
"arch/arc": true,
"arch/arm": true,
"drivers/[^pu]*": true,
"drivers/p[^c]*": true,
"drivers/pcmcia": true,
"drivers/u[^s]*": true,
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/*.crswap": true
},
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true
},
"files.associations": {
"memory_resource": "c"
}
}
宏定义和包含头文件
.vscode/c_cpp_properties.json
中 defines
控制宏定义,includePath
控制头文件搜索 。
{
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"CONFIG_PCI",
"CONFIG_USB_XHCI_DBGCAP",
"MODULE"
],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "gnu++17",
"intelliSenseMode": "linux-gcc-x64"
}
],
"version": 4
}
vscode添加宏定义
VSCode#include头文件时找不到头文件:我的解决方法
3、插件
VScode如何屏蔽不需要的文件及添加搜索的头文件路径
搜索栏语法_vscode files.exclude_一颗不甘坠落的流星的博客-CSDN博客
vscode工程屏蔽不需要的文件(保持搜索便利)_vscode排除文件夹_蓁蓁啊的博客-CSDN博客
vsCode离线安装remote-ssh插件和搭建远程开发环境 - 爱码网
vscode调试时以16进制查看变量_vscode调试查看变量_虔诚的学习者的博客-CSDN博客
简单的 VSCode 插件离线安装方法_乘风破浪kk的博客-CSDN博客
VSCode使用IDEA快捷键,IntelliJ IDEA Keybindings插件使用方法
4、智能编写
VScode 使用之自动生成文件注释_vscode自动生成注释_会打莎士比亚的猴子的博客-CSDN博客
Doxygen与Vscode操作全解_51CTO博客_vscode使用
Vscode 插件 DoxyGen Documentation Generator C语言详细设置_doxygen vscode
C/C++工程的文档自动生成工具
Visual Studio Code(VScode)自动生成头文件
5、VSCode 与 C++
(1)安装
C++ programming with Visual Studio Code
Visual Studio Code 的 C/C++ 支持由Microsoft C/C++ 扩展提供,以在 Windows、Linux 和 macOS 上实现跨平台 C 和 C++ 开发。
安装插件
打开 VS 代码。
选择活动栏上的扩展视图图标或使用键盘快捷键 ( Ctrl+Shift+X )。
搜索’C++'。
选择安装。
(2)调试
(a)使用 CMake 进行跨平台编译与调试
Get started with CMake Tools on Linux
vscode-cmake-tools/README.md at main · microsoft/vscode-cmake-tools · GitHub
Visual Studio Code Variables Reference
用VSCode和CMake编写调试C/C++ - 简书
vscode+cmake下debug报错Target debugging is no longer supported with the legacy driver
(b)launch.json
- gdb
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
// add the directory where our target was built to the PATHs
// it gets resolved by CMake Tools:
"name": "PATH",
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
},
{
"name": "OTHER_VALUE",
"value": "Something something"
}
],
"console": "externalTerminal",
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
- msvc
{
"version": "0.2.0",
"configurations": [
{
"name": "(msvc) Launch",
"type": "cppvsdbg",
"request": "launch",
// Resolved by CMake Tools:
"program": "${command:cmake.launchTargetPath}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [
{
// add the directory where our target was built to the PATHs
// it gets resolved by CMake Tools:
"name": "PATH",
"value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"
},
{
"name": "OTHER_VALUE",
"value": "Something something"
}
],
"console": "externalTerminal"
}
]
}
(c)传参
vscode + cmake命令行参数debug_cmake 命令行 参数_wakaka_Yu的博客-CSDN博客
如何在vscode中将命令行参数传递给cmake?-腾讯云开发者社区-腾讯云
.vscode/settings.json
中 cmake.debugConfig
控制传参 。命令行参数 -code 8
配置如下:
{
"cmake.debugConfig": {
"args": [
"-code",
"8"
]
}
}
☆