在使用C++做题的时候发现每次都要打一遍模板文件,或者复制,这样的 *** 作有点烦。vs中有一个自定义模板可以帮我们解决这个问题
1. 点击左下角齿轮,选择user snippets
输入cpp.json,回车
复制以下代码
{ // 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" // } "C++ template": { "prefix": "cpp", "body": [ "#include", "#include ", "using namespace std;", "int main(){", "", "treturn 0;", "}" ], "description": "C++模板" } }
prefix表示前缀,我这里用的是cpp来带出模板文件,body是带出的内容,description是描述,可以自由修改,"t"是加一个tab,控制缩进
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)