Vscode custom snippet

Time:2020-1-14

1. Add the menu location of “user code snippet”:

File – > Preferences – > User snippet
Vscode custom snippet

Path to the snippet file store:

C:Usersyour-user-nameAppDataRoamingCodeUsersnippetstaosapp.code-snippets

2. Example: add three segments

  • 1) Sclink output HTML
<script></script>
  • 2) Csslink output HTML
<link rel="stylesheet" href="assets/x.css">
  • 3) For 5 output JavaScript
for (var i = 0; i < array.length; i++) {
    var item = array[i];

};

Content in “taosapp. Code snippets”

{
    "scLink": {
        "prefix": "sclink",
        "body": [
            "<script src=\"assets/$1.js\"></script>",
            "\t$2"
        ],
        "description": "script link"
    },
    "cssLink": {
        "prefix": "csslink",
        "body": [
            "<link rel=\"stylesheet\" href=\"assets/$1.css\">",
            "\t$2"
        ],
        "description": "css link"
    },
    "for loop ES5": {
        "prefix": "for5",
        "body": [
            "for (var i = 0; i < array.length; i++) {\n        var item = array[i];\n        $1\n};"
        ],
        "description": "ES5 for code"
    }
}