vscode 模板 snippets

参考链接:

  1. 如何把 vscode snippets 用在项目中提高开发效率 - 知乎 (zhihu.com)
  2. [VS Code]跟我一起在Visual Studio Code 添加自定义snippet(代码段),附详细配置
{
	/*
		 // Place your snippets for C 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"
		}
	*/
	"Header file template": {
		"prefix": "hfile-template",
		"body": [
		   "/**",
		   "  *Copyright(C),2018 - ${CURRENT_YEAR}, Aciga Tech. Co., Ltd.",
		   "  *FileName:   ${TM_FILENAME}",
		   "  *Date:       ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}",
		   "  *Author:     Msming",
		   "  *Version:    1.0",
		   "  *Path:       ${TM_DIRECTORY}",
		   "  *Description:$1",
			"*/",
			"#ifndef ${2:__ACIGA_${TM_FILENAME/(.*)\\.[a-z]+/${1:/upcase}/i}_H_}\n#define $2\n",
			"\n\n\n/* include ***************************************************/",
			"#include <stdio.h>\n#include <stdint.h>\n#include <stdbool.h>",
			"\n\n\n/* Global typedef, enum... ***********************************/",
			"\n\n\n/* Global define *********************************************/",
			"\n\n\n/* Global variables ******************************************/",
			"\n\n\n/* Global function prototype *********************************/",
			"\n\n\n#endif\t// $2 \n"
		],
		"description": "header file template"
   },
   "New .c file template": {
		"prefix": "cfile-template",
		"body": [
			"/**",
			"  *Copyright(C),2018 - ${CURRENT_YEAR}, Aciga Tech. Co., Ltd.",
			"  *FileName:   ${TM_FILENAME}",
			"  *Date:       ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}",
			"  *Author:     Msming",
			"  *Version:    1.0",
			"  *Path:       ${TM_DIRECTORY}",
			"  *Description:$1",
			 "*/",
			 "\n\n\n/* include ***************************************************/",
			 "#include \"${TM_FILENAME_BASE}.h\"",
			 "\n\n\n/* Global typedef, enum... ***********************************/",
			 "\n\n\n/* Global define *********************************************/",
			 "\n\n\n/* Global variables ******************************************/",
			 "\n\n\n/* Global function prototype *********************************/",
			 "\n"
		 ],
		"description": "c source file template"
	},

	  "#ifndef … #define … #endif":{
		"prefix": "def",
		"body": "#ifndef ${1:SYMBOL}\n#define $1 ${2:value}\n#endif\t// ${1:SYMBOL}"
	  },
	  "#include <>":{
		"prefix": "Inc",
		"body": "#include <${1:.h}>"
	  },
	  "#include \"\"":{
		"prefix": "inc",
		"body": "#include \"${1:.h}\""
	  },
	  "#pragma mark":{
		"prefix": "mark",
		"body": "#if 0\n${1:#pragma mark -\n}#pragma mark $2\n#endif\n\n$0"
	  },
	  "main()":{
		"prefix": "main",
		"body": "int main(int argc, char const *argv[]) {\n\t$1\n\treturn 0;\n}"
	  },
	  "For Loop":{
		"prefix": "for",
		"body": "for (${1:i} = 0; ${1:i} < ${2:count}; ${1:i}${3:++}) {\n\t$4\n}"
	  },
	  "Define and For Loop":{
		"prefix": "dfor",
		"body": "size_t ${1:i};\nfor (${1:i} = ${2:0}; ${1:i} < ${3:count}; ${1:i}${4:++}) {\n\t$5\n}"
	  },
	 
	  "Header Include-Guard":{
		"prefix": "once",
		"body": "#ifndef ${1:SYMBOL}\n#define $1\n\n${2}\n\n#endif /* end of include guard: $1 */\n"
	  },
	  "Typedef":{
		"prefix": "td",
		"body": "typedef ${1:int} ${2:MyCustomType};"
	  },
	  "Typedef Struct":{
		"prefix": "tst",
		"body": "typedef struct ${1:StructName} {\n\t$2\n}${3:MyCustomType};"
	  },
	  "Do While Loop":{
		"prefix": "do",
		"body": "do {\n\t$0\n} while($1);"
	  },
	  "While Loop":{
		"prefix": "while",
		"body": "while ($1) {\n\t$2\n}"
	  },
	  "fprintf":{
		"prefix": "fprintf",
		"body": "fprintf(${1:stderr}, \"${2:%s}\\\\n\", $3);$4"
	  },
	  "If Condition":{
		"prefix": "if",
		"body": "if ($1) {\n\t$2\n}"
	  },
	  "If Else":{
		"prefix": "ife",
		"body": "if ($1) {\n\t$2\n} else {\n\t$3\n}"
	  },
	  "If ElseIf":{
		"prefix": "iff",
		"body": "if ($1) {\n\t$2\n} else if ($3) {\n\t$4\n}"
	  },
	  "If ElseIf Else":{
		"prefix": "iffe",
		"body": "if ($1) {\n\t$2\n} else if ($3) {\n\t$4\n} else {\n\t$5\n}"
	  },
	  "Switch Statement":{
		"prefix": "sw",
		"body": "switch ($1) {\n$2default:\n\t${3:break;}\n}$0"
	  },
	  "case break":{
		"prefix": "cs",
		"body": "case $1:\n\t$2\n\tbreak;\n$0"
	  },
	  "printf":{
		"prefix": "printf",
		"body": "printf(\"${1:%s }\\n\", $2);$3"
	  },
	  "scanf":{
		"prefix": "scanf",
		"body": "scanf(\"${1:%s}\\n\", $2);$3"
	  },
	  "Struct":{
		"prefix": "st",
		"body": "struct ${1:name_t} {\n\t$2\n};"
	  },
	  "void":{
		"prefix": "void",
		"body": "void ${1:name}($2) {\n\t$3\n}"
	  },
	  "any function":{
		"prefix": "func",
		"body": "${1:int} ${2:name}($3) {\n\t$5\n\treturn ${4:0};\n}"
	  },
	  "write file":{
		"prefix": "wf",
		"body": "FILE *${1:fp};\n${1:fp} = fopen (\"${2:filename.txt}\",\"w\");\nif (${1:fp}!=NULL)\n{\n\tfprintf(${1:fp},\"${3:Some String\\\\n}\");\n\tfclose (${1:fp});\n}"
	  },
	  "read file":{
		"prefix": "rf",
		"body": "FILE *${1:fp};\n${1:fp} = fopen (\"${2:filename.txt}\",\"r\");\nif (${1:fp}!=NULL)\n{\n\tfscanf(${1:fp},\"${3:Some String\\\\n}\", ${3:&var});\n\tfclose (${1:fp});\n}",
		"description": "read file opeartion including fopen, fscanf and fclose."
	  }
	}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值