0

I use multiple cursors in VSCode (cmd-d/ctrl-d) a lot.

To quit the multiple cursors mode and go to normal single-cursor mode, you can use esc.

However, this will move the cursor back to the first selected word. I want the cursor to stay at the last selected word.

Is there a shortcut / a setting to do that?

Example:

L01   foobar = 42
...
L99   foobar = 99

When I start in L01, ctrl-d on foobar, ctrl-d again I have multiple cursor on L01 and L99. After esc I will have single cursor back on L01. I want to have single cursor on L99.

Note: How to navigate back to the last cursor position in Visual Studio Code? does not help in my case (it doesn't work for multiple cursors)

jakub.g
  • 38,512
  • 12
  • 92
  • 130
  • 1
    See (and upvote) the same issue: https://github.com/microsoft/vscode/issues/88275 On the Backlog for now. – Mark Mar 22 '21 at 18:27

1 Answers1

2

With extension Select By v1.3.1 and the command moveby.calculation you can calculate the new location of the cursor. By using the collapse feature of VSC you are left with 1 cursor.

Define this keybinding

  {
    "key": "ctrl+i escape",
    "when": "editorTextFocus",
    "command": "moveby.calculation",
    "args": {
      "lineNrEx": "selections[selections.length-1].start.line",
      "charNrEx": "selections[selections.length-1].start.character"
    }
  }
rioV8
  • 24,506
  • 3
  • 32
  • 49