vscode设置自定义Tab填充

Vscode自动填充代码

  1. 在 jetbrain(pycharm, IDEA)系列中叫做 keymap,vscode中叫做 snippets
  2. 功能演示
    在这里插入图片描述

vscode 如何设置

  • 点击左下角齿轮状图标 -> user snippets -> 选择 c 语言
    在这里插入图片描述
  • 如下编辑c.json
{   "Print to console": {
		"prefix": "print",
		"body": [
			"printf('$1\\n');",
		],
		"description": "Log output to console"
	},
	"function defined": {
		"prefix": "func",
		"body": [
			"int $1(){",
			"    ",
			"    return 0;",
			"}"
		]
	}
}
  1. 按照格式填写,重要的是 prefix 和 body
  2. 换行时使用数组或者直接写\n
  3. $1 表示光标的位置

猜你喜欢

转载自blog.csdn.net/weixin_42290927/article/details/107808791