当前位置 > it书童 > 编程 > 正文

vscode 添加自定义代码片段

编程 it书童 2020-09-10 11:11:00 0赞 0踩 52阅读 0评论

进入自定义代码片段面板

添加全局代码片段

以 "console.log" 为例:

{
	// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	// is left empty or omitted, the snippet gets applied to all languages. 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:
	"console.log": {
		"scope": "javascript,typescript,html",
		"prefix": "cl",
		"body": [
			"console.log('$1')",
		],
		"description": "console.log"
	}
}

当触发 cl 时就会自动提示补全 console.log()

转载须注明出处:https://www.itshutong.com/articles/702/vscode-add-custom-code-snippet
关于我
一个文科出身的程序员,追求做个有趣的人,传播有价值的知识,微信公众号主要分享读书思考心得,不会有代码类文章,非程序员的同学请放心订阅
发表评论
我有句话,不知当讲不当讲?
要讲之前请先 登录