Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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 ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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"
    }
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading