Creating your first extension
Guide
Step 1
Create a python file inside a folder.
Step 2
Write the code for your extension. For this guide we will use this code:
import vscode
from vscode import InfoMessage
ext = vscode.Extension(name="Test Extension")
@ext.event
async def on_activate():
vscode.log(f"The Extension '{ext.name}' has started")
@ext.command()
async def hello_world(ctx):
return await ctx.show(InfoMessage(f"Hello World from {ext.name}"))
ext.run()
Step 3
Run the python file. It will build the files.
Step 4
Press F5. This will run the extension and open a new vscode window in development mode.
Step 5
Finally, test your command.
- Open the command palette with Ctrl+P in the development window.
- Type
>Hello World
- It should show a popup like this in the bottom right corner