VSCode-Extension(Snippets)

128 阅读1分钟

1. Plugin Development

Installation of scaffolding

Make sure you have Node.js and Git installed, then install Yeoman and VS Code Extension Generator with:

npm install -g yo generator-code | yarn global add yo generator-code

Create project

yo code

Select Code Snippets

Project Catalog

.
├── CHANGELOG.md
├── README.md
├── package.json
├── snippets 
│   └── snippets.code-snippets 
└── vsc-extension-quickstart.md

Writing code snippets

// snippets.code-snippets{    "AIP function component": {        "prefix": "AIP-Snippets",        "body": [            "import React from 'react';",            "",            "const ${1:App} = props => {",            "  return (",            "    <div>",            "      ${0}",            "    </div>",            "  );",            "}",            "",            "",            "export default ${1:App};"        ],        "description": "Code snippet for react function component"    },    "Second": {        "prefix": "Second",        "body": [            "import React from 'react';",        ],        "description": "Code snippet for react function component"    }}

The structure content is as follows

  • AIP function component Code snippet name
  • prefix Code snippet hint
  • body Code fragment content
  • description Code fragment description

Code snippet syntax

vscode snippet-syntax

2. Use

1. Install

npm install -g vsce | yarn global add vsce

2. Publish

Local

vsce package

Application Market

  1. Visit login.live.com/ to log in to your Microsoft account

  2. Visit aka.ms/SignupAzure…

  3. Record Access Token(important)

  4. Visit aka.ms/vscode-crea…

  5.  vsce login [ID]
    
    vsce publishvsce publish patch