The code editor I've been using for the past 20 years (codewright) allows you to set a "select mode". When that is set, all keyboard cursor movements extend the selection. In VS Code, you can extend the selection by holding down the shift key (for example, Shift down-arrow), but I am looking for a way to do that without the shift key.
I have written an extension that mostly does it, but I would have had to do far less work if I could have created a new condition for the "when" clause in keybindings.json
. For example, I would have liked to change
{ "key": "shift+down", "command": "cursorDownSelect",
"when": "editorTextFocus" },
to something like
{ "key": "down", "command": "cursorDownSelect",
"when": "editorTextFocus || extensionSelectionMode" },
{ "key": "down", "command": "cursorDown",
"when": "editorTextFocus" },
Is there a way to do add a such a condition from an extension?
Try using the setContext
command in your extension:
vscode.commands.executeCommand('setContext', 'extensionSelectionMode', true)
See VSCode vim for an example of this in action
We are tracking a better API for setting contexts here: https://github.com/Microsoft/vscode/issues/10471
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With