VScode User Snippets template

VScode User Snippets Template

设置方法

File -> Preferences -> User Snippets -> cpp.json

Template

{
	// 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": "cpp",
	 	"body": [
			"#include <iostream>",
			"#include <cstdio>",
			"#include <cstring>",
			"#include <string>",
			"#include <algorithm>",
			"#include <vector>",
			"#include <map>",
			"#include <set>",
			"#include <queue>",
			"#include <stack>",
			"#include <cstdlib>",
			"#include <cmath>",
			"#define LL long long",
			"#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);",
			"#define MP pair<int,int>",
			"",
			"/*** ",
			"    Author : @JokerNoCry",
			"    Time : $CURRENT_YEAR:$CURRENT_MONTH:$CURRENT_DATE  $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
			" ***/",
			"using namespace std;",
			"const int maxn=1e5+10;",
			"const int mod=1e9+7;",
			"",
			"",
			"",
			"int main()",
			"{",
			"    IO;",
			"    $0",
			"    return 0;",
			"}",
	 	],
	 	"description": "cpp template"
	}
}

说明

prefix 中的代码是用来调用的。
例如: 代码 “prefix” : “cpp” 时:
新建 -> test.cpp -> 输入 -> cpp -> 回车 ; 然后就直接出现了模板中的代码

description 中的内容是对该模板的解释
例如 : 代码 “description” : “cpp template”
新建 -> test.cpp -> 输入 -> cpp ; 按回车之前 选项框选中cpp 后面有备注 内容就是 " cpp template"

body的内容就是模板的主题内容:
每行都需要一个引号,空行也需要引号,引号后面需要逗号。

VScode中的参数:

$0  //创建模板后输入指针的位置。(你输入第一个字符的位置)
$CURRENT_YEAR   //时间中的年
$CURRENT_MONTH   //时间中的月
$CURRENT_DATE   //时间中的日
$CURRENT_HOUR   //时间中的小时
$CURRENT_MINUTE   //时间中的分钟
$CURRENT_SECOND   //时间中的秒数
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值