question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Better multi-cursor support (similar to VSCodeVim) to allow per-cursor motions

See original GitHub issue

It’d be wonderful is this extension could treat each cursor that is generated as its own “context”, and allow normal-mode to work with multiple cursors. I have no idea how complicated this would be to execute given the way that it is implemented, but let me explain.

Say I want to use VSCode’s built-in functionality to add a cursor below the current line while in normal mode. This feels natural to me, and I use things like cmd+d to add cursors to the next occurrence of a given word all the time (for example). When I have added all the cursors I want, my first thought is “okay time to do a motion”, so I execute something like ciw. In VSCodeVim, this behaves as I expect, but in vscode-neovim, it does not.

Here are some gifs that explain things visually a lot better than I can via text. Here’s what happens in neovim:

Screen Recording 2020-10-16 at 19 25 07

And here’s what happens in VSCodeVim:

Screen Recording 2020-10-16 at 19 29 58

In order to get to what I think would be “good multi-cursor support”, I think that the following would probably need to happen:

  • Figure out a way to make it so that if you have multiple cursors, the first instance of ESC is interpreted as “go into normal mode”.
  • When in normal mode + multiple cursors, treat each cursor independently, and send motions/commands to those cursors specifically. If I hit ciw (like I did in the gifs about) each cursor should interpret its “context” to execute the motion on the text it has

Lastly, I’d just like to note that this issue is pretty much the only thing keeping me on VSCodeVim at this point. Aside from that, I really like this extension’s implementation, and it has a ton of upsides in comparison to VSCodeVim’s “emulation-focused” approach (which requires re-inventing the wheel, which feels like an uphill battle). If this extension got first-class multi-cursor support, there’d be nothing holding me back from singing this extension’s praises and using it every single day.

Please let me know if you have any questions about the above details!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:14 (1 by maintainers)

github_iconTop GitHub Comments

13reactions
echayacommented, May 2, 2021

Thanks trkoch, below is to replicate the functionality fully from vim-visual-multi in case anyone wants to copy and paste

    {
        "command": "vscode-neovim.send",
        "key": "ctrl+n",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<c-n>"
    },
    {
        "command": "vscode-neovim.send",
        "key": "ctrl+up",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<c-up>"
    },
    {
        "command": "vscode-neovim.send",
        "key": "shift+up",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<S-up>"
    },
    {
        "command": "vscode-neovim.send",
        "key": "shift+down",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<S-down>"
    },
    {  
        "command": "vscode-neovim.send",
        "key": "shift+left",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<S-left>"
    }, 
    {
        "command": "vscode-neovim.send",
        "key": "shift+right",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<S-right>"
    },
3reactions
trkochcommented, Jan 29, 2021

For anyone who wants to give vim-visual-multi in VSCode a try, make sure to add this to your keybindings.json.

{
        "command": "vscode-neovim.send",
        "key": "ctrl+n",
        "when": "editorTextFocus && neovim.mode != insert",
        "args": "<c-n>"
}

However, I agree vim-visual-multi does not work optimal in VSCode and feels like a hack. I can see adding true multi-cursor support is a challenge and lets hope @asvetliakov finds the time to give it a try.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Better multi-cursor support (similar to VSCodeVim) to allow ...
When in normal mode + multiple cursors, treat each cursor independently, and send motions/commands to those cursors specifically. If I hit ciw ( ......
Read more >
Multiple Cursors - Barbarian Meets Coding
VSCodeVim offers an experimental support for multiple cursors in Visual and Normal modes. Using this experimental feature (that is enabled by default), you...
Read more >
Best Vim alternative to VSCode's Ctrl+D - Stack Overflow
1. Not an answer, but kakoune is a vim-like editor that makes extensive use of multiple cursors (as does micro). · For simple...
Read more >
vim feature similar to Ctrl+D in VSCode? - Reddit
I'm sure vim can do this but I have no idea how, help! ... Yeah, I find that one does not need multiple...
Read more >
The best of both worlds: Visual Studio Code + Vim - Medium
As a developer, I'm always looking for ways to make things more efficient. I want this thing to run faster, and that thing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found