visual-studio-codeline-numbers

Move Cursor Up or Down Multiple Lines at once in VS Code


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).


Solution

  • 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.