VScode创建代码片段

一些重复写的代码我们可以通过代码片段的方式节省时间。

在VSCode的菜单栏中找到, 然后找到想要创建的语言的代码片段,我这里创建了一个Go语言的代码片段。

File-> Preferences-> User Snippets

虽然Go中已经存在很多代码片段了,比如pkgm, fmtpf, fmtpl, fmtpt, 这些经常用的都已经给到了。 如果自己有需要,只需要根据所给注释添加即可

{
	// Place your snippets for go 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"
	// }
	"go-main-template": {
		"prefix": "main",
		"body": [
			"package main",
			"",
			"func main() {",
			"$0",
			"}",
			""
		],
		"description": "a template of go main function"
	}
}

全部评论

相关推荐

目前感觉简历还有很多问题,希望各位能不吝赐教以及非常感谢这位老哥——@黑皮白袜臭脚体育生 的项目,学完一遍感觉受益颇丰
小菜鸡只想转正:校友,我的建议是冗余的最好去掉,突出重点,比如985,211双一流的提示,专业技能调整到个人项目之后的位置。专业技能感觉写的太细了?占用篇幅最好腾出一点给项目经历,如果没写手机号和邮箱,记得加上。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务