rkp333
rkp333

Reputation: 381

Is there a VS Code shortcut to move/select up/down to the next empty line?

I just transitioned from Sublime to VS Code and love it. Wondering if there are equivalent combos, or a way to set them, for jumping/selecting chunks of line, down/up to the next blank line. This is what these looked like for me in ST3:

{"keys": ["ctrl+shift+["], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}},
{"keys": ["ctrl+shift+]"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true, "extend": true}},
{"keys": ["ctrl+{"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": false, "extend": true}},
{"keys": ["ctrl+}"], "command": "move", "args": {"by": "stops", "empty_line": true, "forward": true, "extend": true}},

Upvotes: 18

Views: 7011

Answers (2)

Mark
Mark

Reputation: 182601

This is in Stable v1.54 without an extension. prevBlankLine and nextBlankLine to values have been added to the cursorMove command. See https://github.com/microsoft/vscode/pull/115578.

{
    "key": "ctrl+shift+[",    // whatever keybinding you want
    "command": "cursorMove",
    "args": {
        "to": "prevBlankLine",
        "select": true         // false is the default if omitted
    },
    "when": "editorTextFocus"
},
{
    "key": "ctrl+shift+]",
    "command": "cursorMove",
    "args": {
        "to": "nextBlankLine",
        "select": true         // false is the default if omitted
    },
    "when": "editorTextFocus"
},

Upvotes: 23

david_adler
david_adler

Reputation: 10972

The following plugin meets your requirments I believe

Quote from plugin description

Travel in a text editor by jumping over code "paragraphs", to the closest empty line, optionally selecting text along the way.

The following commands and corresponding default keybindings are provided:

block-travel.jumpUp: alt+up
block-travel.selectUp: alt+shift+up
block-travel.jumpDown: alt+down
block-travel.selectDown: alt+shift+down

Upvotes: 8

Related Questions