VSCode自动配置头文件

自动配置后可以在做题时节省很大的时间.


  1. 按Ctrl+Shift+P进入主命令框
  2. 输入Snippets: Configure User Snippets(配置用户代码片段)
  3. 新建全局代码片段文件
  4. 输入一个代码片段名(例如bits)
  5. 里面有一段示例
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    // Example
    "Print to console": {
    "scope": "javascript,typescript", //文件类型
    "prefix": "log", //触发指令
    "body": [ //模板主体
    "console.log('$1');",
    "$2"
    ],
    "description": "Log output to console" //可以去掉
    }

例如我目前做题用的模板就是

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
"C header": {
"scope":"c, cpp",
"prefix": "header",
"body": [
"#include<bits/stdc++.h>",
"using namespace std;",
"typedef long long ll;",
"#define lowbit(x) ((x)&-(x))",
"int main() {",
"\tios::sync_with_stdio(false);",
"\t$0",
"\treturn 0;",
"}"
]
}


在新建的.cpp文件中输入header就会生成模板了


后期可以一点点完善自己的模板,总的来说还是很方便的.


img_show