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

本秂侑毒 提交于 2021-02-07 14:45:52

问题


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}},

回答1:


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



回答2:


This is in the Insiders' Build for 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
    },
    "when": "editorTextFocus"
},
{
    "key": "ctrl+shift+]",
    "command": "cursorMove",
    "args": {
        "to": "nextBlankLine",
        "select": true
    },
    "when": "editorTextFocus"
},


来源:https://stackoverflow.com/questions/45788119/is-there-a-vs-code-shortcut-to-move-select-up-down-to-the-next-empty-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!