I want to jump x lines vertically when im in selection/highlight mode in VSCode.
That’s what i tried so far:
keybindings.json:
{
"key": "cmd+[Backquote]",
"command": "runCommands",
"args": {
"commands": [
{
"command": "cursorMove",
"args": {
"to": "up",
"by": "line",
"value": 10
}
}
]
},
"when": "editorHasSelection"
}
It works fine without selection:
{
"key": "cmd+[Backquote]",
"command": "cursorMove",
"args": {
"to": "up",
"by": "line",
"value": 10
},
"when": "editorTextFocus"
},
2
Answers
Not exactly what you’re asking for, but it sounds to me kind of like you want the anchor selection commands. Before using your jump command, just set a selection anchor, and then once you’ve jumped to where you want the selection to end, use the command to select from the anchor to your cursor. Then you don’t even need to when-clause for selection context. You can just use a regular cursor-move keybinding for the jumping bit.
If you are trying to select a range of lines from a current selection than this works for me:
By the way, there is no need to use the
runCommands
command – it is for running multiple commands in sequence. This simpler version works: