1. 安裝拓展
Chinese是中文,需要重啟才可以運行,C/C++拓展只是進行語法代碼提示,不需要進行任何配置修改,默認即可。
2. 創建文件
如上圖創建好各級文件夾,其中C++是工作文件夾,.vscode是配置文件夾,里面建一個tasks.json文件,然后把下面內容復制進去
{"version": "2.0.0","tasks": [{"label": "build","type": "shell","command": "g++", // 如果沒有配置環境變量可以直接改成g++.exe的文件路徑"args": ["${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe","-g","-Wall","-fexec-charset=GBK","-std=c++11"],"group": "build","presentation": {"echo": true,"reveal": "always","focus": false,"panel": "shared"},"problemMatcher": "$gcc"},{"label": "run","type": "shell","dependsOn": "build","command": "${fileDirname}\\${fileBasenameNoExtension}.exe","group": {"kind": "test","isDefault": true},"presentation": {"echo": true,"reveal": "always","focus": true,"panel": "shared","showReuseMessage": true,"clear": true}}]
}
3. 綁定快捷鍵
在鍵盤快捷方式中搜索任務,找到任務:運行測試任務
,配置快捷鍵,看個人習慣配置,我習慣是 ctrl + r
至此,環境就配置好了,通過快捷鍵運行代碼,會在終端進行輸入輸出交互。注意,這樣配置是沒有debug能力的,不過競賽選手普遍都是肉眼debug,不需要這個功能。
4. 刷題模板
配置用戶代碼段,選擇cpp,然后把下面的內容復制進去,快捷鍵我配置的是acm
,這樣新創建一個cpp文件,輸入acm
回車就可以直接補全模板,如果想自定義的話也可以自行添加。
{// Place your snippets for cpp here. Each snippet is defined under a snippet name and has a prefix, body and // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the // same ids are connected.// Example:// "Print to console": { 代碼段名稱// "prefix": "log", 代碼段觸發關鍵字// "body": [ 代碼段主體// "console.log('$1');",// "$2"// ],// "description": "Log output to console" 代碼段介紹// }"template": {"prefix": "acm","body": ["#pragma GCC optimize(3, \"Ofast\", \"inline\")","#include<bits/stdc++.h>","#define int long long","#define x first","#define y second","#define pc putchar","#define debug(x) cerr << #x\" = \" << x << '\\n';","using namespace std;","inline int rd() { int X = 0, w = 0; char ch = 0; while (!isdigit(ch)) { w |= ch == '-'; ch = getchar(); } while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar(); return w ? -X : X;}","inline void wr(int x) { if (x < 0) pc('-'), x = -x; if (x > 9) wr(x / 10); pc(x % 10 + '0');}","","void solve()","{"," $0","}","","signed main()","{"," int _ = 1;"," // cin >> _;"," while (_ --) solve();"," return 0;","}"],"description": "template of acm"}
}
5. 鼠標滾輪調節字體大小
設置里面搜索font
,找到如下選項,點擊在setting.json中編輯
在json文件中加入editor.mouseWheelZoom": true
即可
后續想到什么好的功能會繼續更新~