5

I custom a snippet in VS code.And code as below:

"angular2-logger": {
    "prefix": "log",
    "body": [
        "this.log.log('$1');"
    ],
    "description": "使用angular2-logger的log功能"
}

But what if wanna add more snippets?Who can give me a demo?

2 Answers 2

7

Just add a comma in the end after the parentheses and create your next snippet.

For example:

"angular2-logger": {
    "prefix": "log",
    "body": [
        "this.log.log('$1');"
    ],
    "description": "使用angular2-logger的log功能"
},
"Console.log": {
  "prefix": "log",
  "body": [
    "console.log($1);"
  ],
  "description": "Console.log"
}
Sign up to request clarification or add additional context in comments.

Comments

0

After ending your 1st snippet you can add a comma after the } and create another snippet as you did before. For example: (snippet for c++, note the comma)

"#include": {
"prefix": ["#include", "basic"],
"body": [
    "#include<iostream>\r",
    "#include<conio.h>\r",
    "using namespace std;\r",
    "int main()\r",
    "{\r",
    "\r",
    "}"],
"description": "basic starting code"
},
    "cout": {
    "prefix": "count",
    "body": [
    "cout<<\"${1:entercode}\";",
    ""
],
"description": "cout"
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.