vscode flutter 自定义class method 注释模版

474 阅读1分钟

flutter|dart代码设置方法注释模版.

模版如下:test.code-snippets

{
	"class template": {
	  "prefix": "c", //这里是快捷键方法
	  "body": [
		"///",
		"/// author:xxx",
		"/// email:xxx.com",
		"/// description: $1",
		"/// createFileTime:$CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",
		"///"
	  ],
	  "description": "class template"
	},
	"method template": {
	  "prefix": "m", //这里是快捷键方法
	  "body": [
		"/// description: $1",
		"/// [${2:}] :$3",
		"/// return: $4",
	  ],
	  "description": "method template"
	},
}

method template 暂时还没找到如何自动获取:

  • 参数名
  • 返回值类型

如有好的方式,烦请大佬们告知下~

Usage:

在类或方法需要的位置输入快捷键cm然后 enter 即可。 效果:

  • 注释:

image.png

  • 方法注释:

image.png

tips:如 方法注释,按 tab 可以快速切换光标到下一个编辑位置。

如何创建模版,网上很多资料,随便找了个仅供参考 参考