vscode去掉log打出的console.log的分号,以及如何添加新的代码片段

576 阅读1分钟

每次打log的时候它会带出分号,我很烦。我想去掉它。 image.png

其实这就是vscode默认设置的代码片段

步骤: 1. image.png

image.png

3.如果要新加一个片段(重新加载一个vscode) image.png

好了

image.png

{
	// Place your snippets for javascript 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"
	},
  "create Annotation": {
		"prefix": "/**",
		"body": [
			"/**",
			"* @Description",
			"* @author xx",
			"* @date ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE} ${CURRENT_HOUR}:${CURRENT_MINUTE}:${CURRENT_SECOND}",
		    "*/"
		],
		"description": "创建注释"
	}
}

当然如果有人写的时候不会纠结格式,最后prettier格式化就好了。(取消勾选就是不加分号)

image.png