mobile wallpaper 1mobile wallpaper 2mobile wallpaper 3mobile wallpaper 4
493 words
2 minutes
Getting Started with VSCode Plugin Development
2025-03-13

Development Environment#

  1. Node.js

  2. VS Code

  3. Yeoman&generator-code

    To conveniently generate the basic structure of a plugin project, you can use Yeoman and the official VS Code extension generator. Open a terminal and run the following commands to install globally:

    npm install -g yo generator-code

Initial Plugin Framework#

Create Plugin#

yo code

The generator will ask the following questions:

- **Choose Extension Type**:For example “New Extension (TypeScript)” or “New Extension (JavaScript)”.
- **Extension name and description**:Fill in the extension name and description as prompted.
- **Git initialization**:Whether to initialize a Git repository.
- **Package manager**:Choose using npm or yarn.

After generation completes, you will have a basic project structure scaffolded.

Understanding the Structure#

Open the generated project, you will see some important files and directories:

  • package.json

    This file defines the extension’s basic information, dependencies, as well as VS Code activation events and command registrations.

    For example:

    {
    "name": "my-sample-extension",
    "displayName": "My Sample Extension",
    "description": "A simple VS Code extension.",
    "version": "0.0.1",
    "engines": {
    "vscode": "^1.60.0"
    },
    "activationEvents": [
    "onCommand:extension.helloWorld"
    ],
    "main": "./out/extension.js",
    "contributes": {
    "commands": [
    {
    "command": "extension.helloWorld",
    "title": "Hello World"
    }
    ]
    },
    "scripts": {
    "vscode:prepublish": "npm run compile",
    "compile": "tsc -p ./"
    },
    "devDependencies": {
    "typescript": "^4.0.0",
    "vscode": "^1.1.37",
    "@types/node": "^12.0.0"
    }
    }
  • src/extension.ts (or extension.js)

    This is the entry point of the extension; this code runs when the extension is activated.

    For example, a simple sample:

    import * as vscode from 'vscode';
    export function activate(context: vscode.ExtensionContext) {
    console.log('Congratulations, your extension "my-sample-extension" is now active!');
    let disposable = vscode.commands.registerCommand('extension.helloWorld', () => {
    vscode.window.showInformationMessage('Hello World from your VS Code extension!');
    });
    context.subscriptions.push(disposable);
    }
    export function deactivate() {}

Run and Debug#

  • After opening the project, in VS Code’s Debug panel, you will see a configuration named Launch Extension.
  • Press F5; VS Code will start a new Extension Development Host.
  • In the new window, via the Command Palette (Ctrl+Shift+P or Cmd+Shift+P), run the registered command, for example typing “Hello World” to test whether the extension works properly.

Publish Extension#

When development and testing are complete, you may consider publishing the extension to the VS Code Marketplace for others to use:

Specific Development#

Extension Activation#

VS Code extensions are activated according to the activationEvents array in package.json. Here are the main activation event types:

Common Activation Events#

    • Activate the extension immediately when VS Code starts
    • Pros: the extension is always available
    • Cons: may affect VS Code startup performance; not recommended for production environments
  1. onStartupFinished
    • Activate the extension after VS Code finishes starting up
    • Slightly later than the previous, but with less impact on startup performance
  2. onCommand
    • Activate the extension when the user executes a specific command
    • For example: onCommand.helloWorld
  3. onLanguage
    • Activate the extension when opening files of a specific language
    • For example: onLanguage, onLanguage
  4. onView
    • Activate the extension when a specific view becomes visible
    • For example: onView

Other Activation Events#

  1. onUri
  2. onWebviewPanel
    • Activate the extension when creating a specific type of Webview panel
  3. onCustomEditor
    • Activate the extension when opening a custom editor
  4. onDebug
    • Activate the extension when starting a debugging session
  5. onDebugInitialConfigurations
    • Activate the extension when initializing debug configurations
  6. onDebugResolve
    • Activate the extension when resolving a specific type of debug configuration
  7. onFileSystem
    • Activate the extension when accessing a specific filesystem scheme
    • For example: onFileSystem
  8. onTerminalProfile
    • Activate the extension when creating a terminal profile
  9. onAuthenticationRequest
    • Activate the extension when requesting authentication from a specific provider
  10. onSearch
    • Activate the extension when performing a search
  11. onTaskType
    • Activate the extension when executing a task of a specific type
  12. onNotebook
    • Activate the extension when opening a notebook of a specific type
  13. onTerminal
    • Activate the extension when a terminal is created
Share

If this article helped you, please share it with others!

Getting Started with VSCode Plugin Development
https://dreaife.tokyo/en/posts/vscode-plugin-dev/
Author
dreaife
Published at
2025-03-13
License
CC BY-NC-SA 4.0

Some information may be outdated

Related Posts Smart
1
Getting Started with Docker
infra Docker is a technology for solving microservice deployment problems by packaging applications and their dependencies into isolated containers, avoiding inconsistent environments and dependency conflicts. Compared with virtual machines, Docker starts faster and uses fewer resources. Its architecture includes images and containers, and users can share and obtain images through Docker Hub. Basic operations include creating and managing images and containers and using volumes for data persistence and host-container decoupling. Docker Compose can simplify distributed application deployment.
2
A Summary of My Thoughts on the Market on X
market Drawing on complex systems and game theory, this post unpacks the underlying logic of market dynamics, emotional reflexivity, and the consensus underpinning monetary value, helping readers look beyond short-term volatility and develop a deeper understanding of market expectations and inflation transmission.
3
Basic On-Chain Operations for EOA Wallets
WEB3 Quickly master the core on-chain operations of Web3 wallets. Covers the principles behind creating EOA and HD wallets, mnemonic generation and the BIP derivation process, an in-depth look at SIWE and EIP-712 on-chain verification, and the full lifecycle of transaction construction, signing, and broadcasting to help you understand the underlying logic of wallets.
4
About an EOA Wallet Signature Verification and Related Content
WEB3 A developer-focused guide to EOA wallet signature verification, covering secp256k1, ECDSA r/s/v signatures, public key recovery, keccak-256 address derivation, and how SIWE proves wallet ownership without exposing the private key.
5
An EVM wallet login interface for EOAs
WEB3 A practical EVM/EOA wallet login walkthrough covering connect wallet, SIWE-style messages, wagmi signing, nonce handling, and backend verification, explaining why login separates address connection from signature-based ownership proof.

Table of Contents