Reputation: 177
I want to do key-binding for custom command in my vs-code extension. I have written below code but not working.
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
const savecommand = 'custom-command.key-binding';
const saveComamndHandler = vscode.commands.registerCommand(savecommand, () => {
vscode.window.showInformationMessage("Saved file");
});
context.subscriptions.push(saveComamndHandler);
}
package.json:
"main": "./dist/extension.js",
"activationEvents": [
"onCommand:custom-command.key-binding"
],
"categories": [
"Keymaps"
],
"contributes": {
"keybindings": [
{
"key": "ctrl+s",
"command": "custom-command.key-binding'"
}
]
},
can anyone help me?
Upvotes: 1
Views: 430
Reputation: 180659
Is custom-command
the name
of your extension?
You have a typo below
"contributes": {
"keybindings: [
{
"key": "ctrl+s",
// I see you have a stray single quote in the following line
// "command": "custom-command.key-binding'"
"command": "custom-command.key-binding"
}
]
}
Upvotes: 1