Reputation: 1370
I would like to make the "when" clause of a specific keyboard shortcut be only when a specific extension (the Python extension in my case) is enabled/active i.e. when I am busy working with a python project.
How can I accomplish this?
Upvotes: 1
Views: 397
Reputation: 990
There is extension context for key bindings but I think it can only be used inside extension. Although in keybindings.json extension
key is checked because adding it breaks the shortcut execution, it surely doesn't work like in example from the docs.
Try "when": "extension == 'ms-python.python'"
or "when": "extension == 'ms-python.python' && extensionStatus == 'installed'"
You could probably make simple extension of your own that would check ms-python.python status and provided you with a shortcut.
Best alternative is relying on document language, like rioV8 suggested:
"when": "editorLangId == 'python'"
Upvotes: 1
Reputation: 28673
you can add this to the when
clause of the key binding
editorLangId == 'python'
Upvotes: 0