Home > database >  vscode define select n lines shortcut
vscode define select n lines shortcut

Time:07-19

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 ?

CodePudding user response:

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"
    }
  • Related