如何更改VS code !+tab默认生成的html初始化代码模板的meta值

504 阅读1分钟

在vscode中有自定义代码片段的功能,如图 在这里可以设置用户的代码片段

然后可以新建一个全局的代码片段

往里面添加代码,格式如下

{
	"HTML template": {
		"prefix": "html",
		"body": [
			"<!DOCTYPE html>",
			"<html lang=\"zh-CN\">",
			"<head>",
			"\t<meta charset=\"UTF-8\">",
			"\t<title>Document</title>",
			"\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
			"\t<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">",
			"</head>",
			"<body>",
			"\t$0",
			"</body>",
			"</html>"
		],
		"description": "Simple HTML5 starting point"
	},
	"MY HTML template": {
		"prefix": "myhtml",
		"body": [
			"<!DOCTYPE html>",
			"<html lang=\"zh-CN\">",
			"<head>",
			"\t<meta charset=\"UTF-8\">",
			"\t<title>Document</title>",
			"\t<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no,viewport-fit=cover\">",
			"\t<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">",
			"</head>",
			"<body>",
			"\t$0",
			"</body>",
			"</html>"
		],
		"description": "Simple HTML5 starting point"
	}
}

看效果

相关链接

segmentfault.com/q/101000001…

segmentfault.com/q/101000000…

code.visualstudio.com/docs/editor…