Note: I have searched in Google and other SO posts, but none of them have helped me.
I know that we can move up or down with Alt Arrow. Is there a way to move, let's say 25 lines up, at once? I don't want to press Alt ↑ 25 times.
Is there a plugin or a built-in feature to do this?
The reason I'm asking is that it's easier to move multiple lines at once due to the relative line numbers feature in VS Code.
I don't want to specify each number in keybindings.json (As seen here).
CodePudding user response:
You can use multi-command
Like in Photoshop when you move something Arrow moves 1 pixel, Shift Arrow moves 20 pixels.
The Arrow key has no modifier combo unused so we have to choose a different key.
New keybindings to move up or down 10 lines
{
"key": "alt numpad8", // or any other key combo
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction",
"editor.action.moveLinesUpAction"
]
},
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "alt numpad2",
"command": "extension.multiCommand.execute",
"args": {
"sequence": [
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction",
"editor.action.moveLinesDownAction"
]
},
"when": "editorTextFocus && !editorReadonly"
}
Maybe you have to add a little delay
"args": {
"interval": 50,
"sequence": [
CodePudding user response:
To make it easier to navigate the cursor in blocks of lines you could set a keybinding to jump 10 lines up or down at once (in your keybindings.json):
{
"key": "ctrl up", // whatever keybinding you want
"command": "cursorMove",
"args": {
"to": "up",
"by": "line",
"value": 10 // change this if you want
},
"when": "editorTextFocus"
},
{
"key": "ctrl down", // whatever keybinding you want
"command": "cursorMove",
"args": {
"to": "down",
"by": "line",
"value": 10 // change
},
"when": "editorTextFocus"
}
As noted in the comments, this comes from https://stackoverflow.com/a/48568520/836330 so upvote that.
