一、输入!+tab键,或者!+enter,自动生成html:5的模板

在vscode中使用html模板_自动生成

 

 二、自定义模板

打开File(文件)–>Preferences(首选项)–>User Snippets(用户片段)–>在文本框中输入“html”(将打开html.json,在该文件中输入对应的模板保存即可)–>在空白html文件中输入“h”+回车,即可生成自定义的模板、

在vscode中使用html模板_自定义_02

 

 在vscode中使用html模板_快捷键_03

 

 在vscode中使用html模板_自定义_04

 

在vscode中使用html模板_自定义_05在vscode中使用html模板_自定义_06
{
    // Place your snippets for html 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"
    // }
    "html template":{
        "prefix":"h",//使用模板的快捷键
        "body": [
            "<!DOCTYPE html>",
            "<html lang=\"en\">",
            "<head>",
            "\t<meta charset=\"UTF-8\">",
            "\t<title>Document</title>",
            "</head>",
            "<body>",
            "\t $0",//$0鼠标停留的位置
            "</body>",
            "</html>"
        ],
        "description": "html模板"//模板的描述
    }
}
html.json