1、vscode中的变量
https://code.visualstudio.com/docs/editor/variables-reference
预定义变量
${workspaceFolder} - /home/your-username/your-project
${workspaceFolderBasename} - your-project
${file} - /home/your-username/your-project/folder/file.ext
${relativeFile} - folder/file.ext
${relativeFileDirname} - folder
${fileBasename} - file.ext
${fileBasenameNoExtension} - file
${fileDirname} - /home/your-username/your-project/folder
${fileExtname} - .ext
${lineNumber} - line number of the cursor
${selectedText} - text selected in your code editor
${execPath} - location of Code.exe
当预定义变量满足不了使用需求时,可以在 VSCode 中设置自定义变量,并通过 ${config:Name} 的方式调用
2、如何设置自定义变量
自定义变量可以在 settings.json 中配置,即 VSCode 的 setting 文件。VSCode 设置分为 “用户配置” 和 “工作区配置”
对应的 settings.json 也有两个。对于通用配置,可以在 “用户配置” 中添加;而针对于工作区的特殊情况,则可以在 “工作区配置” 中添加。
2、配置文件详解
launch.json介绍
{
"version": "0.2.0", //版本信息
"configurations": [
{
},
{
// 配置名称,将会在启动配置的下拉菜单中显示
"name": "C++ Launch (GDB)",
// 配置类型,这里只能为cppdbg
"type": "cppdbg",
// 请求配置类型,可以为launch(启动)或attach(附加)
"request": "launch",
// 调试器启动类型,这里只能为Local
"launchOptionType": "Local",
// 生成目标架构,一般为x86或x64,
// 可以为x86, arm, arm64, mips, x64, amd64, x86_64
"targetArchitecture": "x86",
// 将要进行调试的程序的路径
"program": "${workspaceRoot}",
// 程序调试时传递给程序的命令行参数,一般设为空即可
"args": [],
// 指定连接的调试器,可以为gdb或lldb。但目前lldb在windows下没有预编译好的版本。
"MIMode": "gdb",