如上图,点击文件 – 首选项 – 用户代码片段,点击新建代码片段:


其中标红部分是一个完整的示例,取消注释,即能达到输入 log 字符,按tab键将输出:console.log(‘光标’)的效果,并且再按tab键,可以到达下一行。


    // Place your 全局 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:
     “Print to console”: {
        “scope”: “html”,
        “prefix”: “vuehtml”,
        “body”: [
            “<!DOCTYPE html>”,
            “<html lang=\”en\”>”,
            ” <meta charset=\”UTF-8\”>”,
            ” <meta name=\”viewport\” content=\”width=device-width, initial-scale=1.0\”>”,
            ” <meta http-equiv=\”X-UA-Compatible\” content=\”ie=edge\”>”,
            ” <title>$0</title>”,
            ” <script src=\”https://cdn.jsdelivr.net/npm/vue/dist/vue.js\”></script>”,
        “description”: “a vue html template”


<!DOCTYPE html>
<html lang=”en”>
<meta charset=”UTF-8″>
<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
<meta http-equiv=”X-UA-Compatible” content=”ie=edge”>
<script src=”https://cdn.jsdelivr.net/npm/vue/dist/vue.js”></script>


Snippets in Visual Studio Code


ikbc C104 机械键盘 有线键盘 游戏键盘 104键 原厂cherry轴 樱桃轴 吃鸡神器 笔记本键盘 白色 茶轴 自营


码中人 微信公众号