VS Code 调教日记
作者:互联网
VS Code 调教日记
关于.vscode的配置
c_cpp_properties.json
c_cpp插件配置
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}\\**"
],//项目文件根目录
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],//一般不用改
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "E:\\MYPROGRAM\\ENV\\MinGW\\mingw64\\bin\\g++.exe",//编译器的路径
"cStandard": "c11",//C标准
"cppStandard": "c++14",//C++标准
"intelliSenseMode": "${default}"//智能模式,默认就行
}
],
"version": 4
}
launch.json
前者编译+运行,后者编译+调试
F5启动(启动最近启动的模式),也可以到Run界面手动开启
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(Windows) 启动",
"type": "cppvsdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}",
"args": [
"/C",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"&",
"pause"
],
"stopAtEntry": false,
"cwd": "${fileDirname}",
"environment": [],
"preLaunchTask": "C/C++: g++.exe 生成活动文件",
"console": "externalTerminal"
},
{
"name": "(gdb) 启动",// 配置名称,将会在启动配置的下拉菜单中显示
"type": "cppdbg",// 配置类型,这里只能为cppdbg
"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)
"program": "${fileDirname}\\${fileBasenameNoExtension}",// 将要进行调试的程序的路径
"args": [],// 程序调试时传递给程序的命令行参数,一般设为空即可
"stopAtEntry": false,// 设为true时程序将暂停在程序入口处,一般设置为false
"cwd": "${fileDirname}", // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录
"environment": [],
"MIMode": "gdb",
"miDebuggerPath": "E:\\MYPROGRAM\\ENV\\MinGW\\mingw64\\bin\\gdb.exe",// miDebugger的路径,注意这里要与MinGw的路径对应
"preLaunchTask": "C/C++: g++.exe 生成活动文件",// 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc
"externalConsole": true,// 调试时是否显示控制台窗口,一般设置为true显示控制台
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "将反汇编风格设置为 Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
tasks.json
编译配置
Ctrl+Shift+B编译
{
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: g++.exe 生成活动文件",
"command": "g++",
"args": [
"-fdiagnostics-color=always",
//"-fexec-charset=GBK",
//"-finput-charset=UTF-8",
//"-finput-charset=GB2312",//这三句是坑
"-std=c++14",
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
],
"options": {
"cwd": "${fileDirname}"
},
"problemMatcher": [
"$gcc"
],
"presentation": {
"echo": true,
"reveal": "silent",
"panel": "shared",
"showReuseMessage": false,
"clear": false
},
"group": {
"kind": "build",
"isDefault": true
},
"detail": "调试器生成的任务。"
},
],
"version": "2.0.0"
}
关于C_CPP插件自带的代码格式化用法
首先要把设置->文本编辑器中的Format On Save打开
再将C/CPP插件中的Formatting调成vcFormat
最后在C/CPP插件里面关于格式化的配置自定义即可
关于代码模板的用法
在设置->用户代码片段->选择Cpp文件->进行如下类似自定义
prefix用于输入前缀匹配,之后只要在文本中输入这个就可以将文本替换
$符号用于聚焦光标
{
"ACM-MODLE": {
"prefix": "acm",
"body": [
"#include <bits/stdc++.h>",
"$1",
"using namespace std;",
"$2",
"int main() {",
"\tstd::ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);",
"\t$3",
"\t",
"\treturn 0;",
"}"
],
"description": "Init an acm model."
}
}
标签:插件,Code,false,gdb,fileDirname,调教,VS,true,exe 来源: https://www.cnblogs.com/BlankYang/p/16286979.html