一、常用的快捷鍵
1)注釋 ctrl+/
- 隱藏左側(cè)欄目 ctrl+b
3) 隱藏控制臺終端 ctrl+~
4) 新建windows ctrl shift n
5) 折疊區(qū)域代碼 ctrl shift [ 顯示區(qū)域代碼ctrl shift ]
縮進(jìn)ctrl [ 和 crtl ]
二、編寫c++ 配置的文件
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch", //配置名稱,會在啟動配置的下拉菜單中顯示
"type": "cppdbg", //配置類型,只能為cppdbg
"request": "launch", //請求類型,可以為launch或attach
"program": "${workspaceFolder}/a.out", //將要調(diào)試的程序的路徑
"args": [], //調(diào)試時(shí)傳遞給程序的命令行參數(shù)
"stopAtEntry": false, //設(shè)為true程序會暫停在入口處
"cwd": "${workspaceFolder}", //調(diào)試程序時(shí)的工作目錄
"environment": [], //環(huán)境變量
"externalConsole": true, //調(diào)試時(shí)是否顯示控制臺窗口
"MIMode": "gdb", //指定連接的調(diào)試器,可以為gdb或lldb
"miDebuggerPath": "/usr/bin/gdb", //gdb路徑
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "build" //調(diào)試開始前執(zhí)行的任務(wù),一般為編譯程序
}
]
}
task.json
{
"version": "2.0.0",
"tasks": [
{
"label": "build", //在launch.json文件中有用到
"type": "shell",
"command": "g++",
"args": [
"-g", "main.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
按ctrl + shift + P打開vscode控制臺(記住此快捷鍵,以后經(jīng)常用),輸入C/Cpp: Edit configurations,就自動生成了一個c_cpp_properties.json文件,這樣你就可以在該文件中編寫參數(shù)來調(diào)整設(shè)置。