admin管理员组

文章数量:1290263

In VS Code, let's say I have three lines selected:

Is there a way to convert that to a column select?

This would be an extremely handy shortcut for me because I use Space Block Jumper to easily select blocks of text with a single keyboard shortcut, and quite often I find a similar need to edit a block of text column-wise.

In VS Code, let's say I have three lines selected:

Is there a way to convert that to a column select?

This would be an extremely handy shortcut for me because I use Space Block Jumper to easily select blocks of text with a single keyboard shortcut, and quite often I find a similar need to edit a block of text column-wise.

Share Improve this question asked Feb 20 at 9:30 Robert Mark BramRobert Mark Bram 9,75510 gold badges56 silver badges76 bronze badges 2
  • You can hold shift and alt as you select to select in blocks, is that what you want? – Neil Butcher Commented Feb 20 at 9:34
  • Thanks @NeilButcher, I use that already, and it's fine for two or three lines. But I am looking for a way to make it easier to column select ten, twenty lines etc with a single keyboard shortcut. Turning a block select into a column select was one mechanism I hoped for. – Robert Mark Bram Commented Feb 21 at 0:51
Add a comment  | 

2 Answers 2

Reset to default 1

The only solution I know is AltShiftI Add Cursors to Line Ends, that gives you the cursors but without the selection.

You can then do ShiftHome to select the lines, or just Home to have the cursors at the beginning of each line like in your second screenshot.

Here's what HolyBlackCat suggested as a custom keyboard shortcut, which you can put in keybindings.json:

{
    "key": "ctrl+b", // TODO: whatever you want
    "command": "runCommands",
    "args": { "commands": [
        "editor.action.insertCursorAtEndOfEachLineSelected",
        "cursorHomeSelect",
        "cursorHomeSelect", // add another if you want to go to actual start of line rather than just start of non-whitespace content
    ]},
    "when": "editorTextFocus",
},

本文标签: VS Codecan I turn a block selection into a column selectionStack Overflow