Common Capabilities are important building blocks for your extensions. Almost all extensions use some of these functionalities. Here is how you can take advantage of them.
Command is central to how VS Code works. You open the Command Palette to execute commands, bind custom keybindings to commands, and right-click to invoke commands in Context Menus.
An extension could:
- Register and execute commands with the
- Make commands available in the Command Palette with the
Learn more about commands at the Extension Guides / Command topic.
An extension can register custom Context Menu items that will be displayed in different parts of the VS Code UI on right-click. Read more at the
contributes.menus Contribution Point.
There are four options for storing data:
ExtensionContext.workspaceState: A workspace storage where you can write key/value pairs. VS Code manages the storage and will restore it when the same workspace is opened again.
ExtensionContext.globalState: A global storage where you can write key/value pairs. VS Code manages the storage and will restore it for each extension activation.
ExtensionContext.storagePath: A workspace specific storage path pointing to a local directory where your extension has write/read access. This is a good option if you need to store large files that is accessible only from current workspace.
ExtensionContext.globalStoragePath: A global storage path pointing to a local directory where your extension has write/read access. This is a good option if you need to store large files that is accessible from all workspaces.
The extension context is available to the
activate function in the Extension Entry File.
Almost all extensions need to present information to the user at some point. VS Code offers three APIs for displaying notification messages of different severity:
Extensions can use the
vscode.window.showOpenDialog API to open the system file picker and select files or folders.
You can use the
vscode.Progress API for reporting progress updates to the user.
Progress can be shown in different locations using the
- In the Notifications area
- In the Source Control view
- General progress in the VS Code window
The Progress Sample illustrates this API.