'Key-Binding for custom command in a vscode extension
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?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
