Pablo
Pablo

Reputation: 3514

vscode define select n lines shortcut

I have some custom shortcuts to move with cmd+up and cmd+down with intervals of 5 lines.

   {
        "key": "cmd+up",
        "command": "cursorMove",
        "args": {
            "to": "up",
            "by": "line",
            "value": 5
        },
        "when": "editorTextFocus"
    },
    {
        "key": "cmd+down",
        "command": "cursorMove",
        "args": {
            "to": "down",
            "by": "line",
            "value": 5
        },
        "when": "editorTextFocus"
    },

What I would like is when pressing shift+cmd+[up,down] to select 5 lines up and down. I've found that there are a few "commands" such as {cursorDownSelect, cursorPageDownSelect, CursorEndSelect} but none of them allow me to define some args to jump a few lines, does anybody know how to do it ?

Upvotes: 0

Views: 105

Answers (1)

Mark
Mark

Reputation: 180631

You can add the select option to the cursorMove command. Search for cursorMove at this commands page: https://code.visualstudio.com/api/references/commands

  {
        "key": "cmd+up",
        "command": "cursorMove",
        "args": {
            "to": "up",
            "by": "line",
            "value": 5
            "select": true       // the default is false
        },
        "when": "editorTextFocus"
    },
    {
        "key": "cmd+down",
        "command": "cursorMove",
        "args": {
            "to": "down",
            "by": "line",
            "value": 5,
            "select": true
        },
        "when": "editorTextFocus"
    }

Upvotes: 1

Related Questions