Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feedback about Multi-Cursor Mode #824

Closed
johnfn opened this issue Oct 3, 2016 · 120 comments
Closed

Feedback about Multi-Cursor Mode #824

johnfn opened this issue Oct 3, 2016 · 120 comments

Comments

@johnfn
Copy link
Member

johnfn commented Oct 3, 2016

This is a thread for feedback about Multi-Cursor Mode. I don't use it all that often, so I'm open to any and all suggestions about what it should do or be like.

@jgoz
Copy link
Contributor

jgoz commented Oct 3, 2016

As of 0.3.0 (Windows, Code 1.5.3), it's very difficult to actually get into Multi-Cursor Mode from Normal Mode. Using the Add Cursor Above/Below shortcuts in Normal mode, it will expand the cursor appropriately but then the first command that gets invoked will only apply to the first line. See the following screencast:

multicursor

The commands I tried were in this order:

  • dw
  • x
  • i

Note that I was only able to get to mult-cursor/normal mode by first entering Insert mode, adding cursors, making a change, and then exiting into Normal mode again.

@johnfn
Copy link
Member Author

johnfn commented Oct 3, 2016

Thanks for the feedback @jgoz! I don't actually have a Windows machine, so that probably explains some of your problems. :P

I'm curious how the new command gc that we added works for you?

In the meantime I'll see if I can find someone with a Windows machine to do some testing.

@jgoz
Copy link
Contributor

jgoz commented Oct 3, 2016

I'm curious how the new command gc that we added works for you?

I'm not sure exactly how gc is supposed to work, but here's what happens on my machine:

  • gc -> highlight all occurrences of a string
  • any other command (d, etc): only execute command on the first string that was selected

If I keep doing gc, it will add the selections one-by-one and then commands I execute will operate on those selections. I can do another screencast if my description was unclear :)

@johnfn
Copy link
Member Author

johnfn commented Oct 3, 2016

gc should add another cursor at the next instance of the word. It should be exactly the same as cmd-d.

Then once you've added a bunch of cursors, you should be able to run vim commands on all of them.

If I keep doing gc, it will add the selections one-by-one and then commands I execute will operate on those selections.

This sounds like desired behavior, at least for "gc does the same as ctrl-d". Am I wrong?

@johnfn
Copy link
Member Author

johnfn commented Oct 3, 2016

@jgoz I think I see the bug for Windows. Give me a sec.

@jgoz
Copy link
Contributor

jgoz commented Oct 4, 2016

This sounds like desired behavior, at least for "gc does the same as ctrl-d". Am I wrong?

Sounds like it. I tested this out on my Mac at home and it behaves the same as Cmd+D.

One issue I did notice with both Cmd+D and gc is that (in Normal mode) if you run it on a word with a trailing comma, the comma will be part of the selection in the first instance. I can file this as a separate issue if you like.

@jgoz I think I see the bug for Windows. Give me a sec.

👍

@Platzer
Copy link
Contributor

Platzer commented Oct 4, 2016

Hi i use (Vscode 1.6.0 Insider, Windows 7, Vim 0.3.0), it seams that VsCodeVim eats the Add Cursor Above/Below shortcuts:
vscodevim eats shortcut
If i uninstall the extension the shortcuts working just fine.

And you can see another issue in the gif. If i add a new cursor below in normal mode an switch to insert mode only the main cursor is acitve.

@habamax
Copy link

habamax commented Oct 5, 2016

Yep, windows 10 and gc only highlights multiple selections but any operation I do are applied only for the first one.

@johnfn
Copy link
Member Author

johnfn commented Oct 5, 2016

Yeah, sorry about that! It seems like it's no good on Windows. Once #835 is done I will address those problems and push out a new version!

@octref
Copy link
Contributor

octref commented Oct 5, 2016

Thanks a lot for the work! I didn't know the multi-cursor is the one with cmd+alt+down (just looked at it and it looks awesome), so I used Ctrl+V to activate it:

The blinking cursor is a bit annoying.

mc

And here I'm pressing w and b.

w

cmd+alt+down version doesn't have these issues. I'd suggest letting Ctrl-V use the multi-cursor implementation, as all its use cases are covered by multi-cursor. IIRC that is what Atom and Sublime's Vim implementation was using.

Again, thanks for the multi-cursor support. It's amazing.

@frederickfogerty
Copy link
Contributor

frederickfogerty commented Oct 5, 2016

Hey there @johnfn, thanks for creating this. Works great when using vim commands, but there is no interoperability with VSCode's native selections, is this right? i.e. if I select text using Shift + arrow keys in insert mode, and press command + d, I get the following:

The first part is when I use VSCode's selections (shift+option+arrow key) + cmd-d, the last part is using Vim selections (vaw) + cmd-d.

oct-06-2016 10-11-12

Would this fixed by #832?

@vogler
Copy link

vogler commented Oct 6, 2016

Some strange behavior I noticed:

  1. alt+cmd+up/down (editor.action.insertCursor{Above/Below}) only works in normal mode - why not in insert mode?
  2. alt-clicking for multiple cursors in normal mode, after i, only the first cursor remains

@maciej-trebacz
Copy link

@johnfn On macOS Sierra, when I try to highlight a word and then use "Replace all occurrences" feature it doesn't work property, only the originally highlighted word gets replaced, while for all the others the text gets appended.

@zmx
Copy link

zmx commented Oct 11, 2016

Use cw command on last word of lines will cause lines incorrectly join together.
macOS 10.11

@d-sparks
Copy link

Has anybody tried using multiple cursors on Linux? I'm having no luck at all, neither with editor.action.addSelectionToNextFindMatch nor editor.action.insertCursorAbove. In both cases any action carried out only hits the first cursor instance.

@colltoaction
Copy link

colltoaction commented Oct 27, 2016

On Windows, latest VSCode and VsCodeVim:

If I'm in normal mode, hit Ctrl+D to select multiple words, then hit i to insert, it rolls back to one cursor. Same with all other insertion commands. c doesn't even work.

If I'm in insert mode, hit Ctrl+D to select multiple words, then try to move the cursors using the arrow keys, it rolls back to one cursor.

gc command doesn't let me i or a, only I or A. Is this the behavior of the visual mode multi cursor? What's the benefit?

Thanks for your support!

@johnfn
Copy link
Member Author

johnfn commented Oct 29, 2016

Lots of good feedback here. Thanks, guys.

@tinchou The reason that i and a don't work is because you start off in visual mode in multi cursor mode, and i and a don't do anything in visual mode. Hit <esc> to go back to normal multi cursor mode, and then use i or a.

I have no idea why ctrl-d isn't working for you, though. That's definitely a bug.

@d-sparks I definitely haven't tried Linux, so that could very well be possible, unfortunately.

@zontafil
Copy link

zontafil commented Nov 2, 2016

using linux and I'm having the same behaviour as @d-sparks

@ta3pks
Copy link

ta3pks commented Nov 2, 2016

I also can not use multi cursor properly in ubuntu and none of the vscode shortcuts work either such as add cursor below

@kuntau
Copy link

kuntau commented Nov 4, 2016

VS Code 1.7.1 and Vim 0.4.1 on OS X 11.6

cmd+d or gc correctly select multiple occurrence but I can't enter insert mode, tried s c i a none of them work

@johnfn
Copy link
Member Author

johnfn commented Nov 4, 2016

You go into visual mode by default, because you're selecting text. Press esc to go into normal mode like normal and then i also like normal.

@kuntau
Copy link

kuntau commented Nov 4, 2016

@johnfn I think that is not the expected behavior. When I select a block of text, I expect c or s to replace the text, not to enter insert mode and C-w to delete word. Even if I Esc to normal mode, ciw or cw still doesn't work.

Should we follow terryma/vim-multiple-cursors behavior? Since it will provide consistent experience across editor

@johnfn
Copy link
Member Author

johnfn commented Nov 5, 2016

Oh I see. Yeah, it is broken. That's a bug. c and d should definitely work.

@Platzer
Copy link
Contributor

Platzer commented Nov 5, 2016

@johnfn take a look at #1029 should fix d and c.

@3ximus
Copy link

3ximus commented Dec 18, 2016

@johnfn I'm noticing this behavior on Linux:
Using Visual Block and then using I to insert at the beggining of Visual Block it inserts one character before.
Better demonstrated with some gifs:
how it should work (gvim):
vim
how it works:
code_bad
it actually works with two columns selected:
code

@mrmurphy
Copy link

mrmurphy commented Feb 2, 2017

I think it'd be super helpful to have surround.vim mode work with multiple cursors. Right now the surround is only applied to the first cursor:

kapture 2017-02-02 at 7 00 44

@blaind
Copy link

blaind commented Feb 6, 2017

Is there a way to enter the multi-cursor mode directly from the insert mode on Linux/Windows (same as cmd-d in Mac)? E.g. steps:

  • Go to insert mode (i)
  • Select some code (keep shift down, press right multiple times)
  • [do something] -> should add second cursor to next occurrence of selected code

@alex-ketch
Copy link

alex-ketch commented Mar 11, 2017

@blaind: It was really throwing me off as well, being unable to go into multiple-cursor mode from insert mode. Managed to fix it with custom keyboard shortcuts though.

Change cmd to ctrl if on windows (I think?).
Never mind, the custom shortcuts below seem to cause some issues. Noticable when using up/down arrows to select autocomplete options.

[{
  "key": "cmd+d",
  "command": "editor.action.addSelectionToNextFindMatch",
  "when": "editorTextFocus"
},
{ "key": "left",
  "command": "cursorLeft",
  "when": "editorTextFocus"
},
{ "key": "right",
  "command": "cursorRight",
  "when": "editorTextFocus"
},
{ "key": "down",
  "command": "cursorDown",
  "when": "editorTextFocus"
},
{ "key": "up",
  "command": "cursorUp",
  "when": "editorTextFocus"
}]

@montogeek
Copy link

How can I select all const in this code?
image

My usual workflow is to select const, Cmd+D to select other occurrences, but it is not working

@mtjn
Copy link

mtjn commented Jun 28, 2019

Hi, is it possible to change the default behaviour for the following situation?

Condition: multi-cursor insert mode
Action: press escape
Current result: change to multi-cursor normal mode

Desired result: change to single-cursor insert mode

@HanggiAnggono
Copy link

when i move multiple cursors up or down the cursors will be merged as one cursor again, why is that?

@austeane
Copy link

When I am in multicursor insert mode I'd like to be able to highlight each word seperately like I would in non-vim multicursor mode. Is this possible?

@quezak
Copy link

quezak commented Sep 6, 2019

Hi, is it possible to change the default behaviour for the following situation?
...
Desired result: change to single-cursor insert mode

Pls don't change the default, that proposed behavior would be annoying in my case. I don't care if it was behind some magic settings swtich though :)

@quezak
Copy link

quezak commented Sep 6, 2019

I needed to add '<C-d>': false in vim.handleKeys in settings to make ctrl-d work the same as g b. Before that, I tried to just remove the keybinding for extension.vim_ctrl+d in keyboard preferences, which resulted in weird behavior.

Question: is there some equivalent of ctrl-k ctrl-d (skip this occurence and go to next one with the next cursor) with g something? Like g b is the equivalent of ctrl-d?

@ralphcallaway
Copy link

ralphcallaway commented Sep 13, 2019

is there an equivalent of super-L with vscode vim? goal would be to drop into normal mode with cursors at the end of each lien

for example i paste some text from a website that includes line numbers

1. function someSample() {
2.     doStuff();    
3. }

without vim enabled, i'd do the follow

  1. super-a (select all)
  2. super-L (add cursors at end of all select lines)
  3. super-LEFT (move to start of line)
  4. alt-shift-right (select numbers)
  5. shift-right, shift-right (select ". ")
  6. delete (delete line numbers)
  7. esc (drop out of multi-line mode)

then i could get

function someSample() {
     doStuff();    
}

i realize visual block mode can do this to some extent, but my understanding is i only get one operator and then i'm back in normal mode where i entered visual mode

also realize i could do a macro and repeat on the lines, but i struggle to get those right the first time, and if i could skip doing the macro and go right to the normal commands, why not shorten the path a bit?

goal would be to

  • make some selection (not necessarily the whole file and same cursor location)
  • enter multi-cursor normal mode at the end of each line
  • multiple clip boards at each cursor
  • independent motion at each cursor

seems like the idea is present in the current implementation, just need a little easier route to drop into it

disclaimer: i'm a vim noob, apologies if i'm missing something obvious

@ralphcallaway
Copy link

ralphcallaway commented Sep 13, 2019

@mtjn

Hi, is it possible to change the default behaviour for the following situation?

Condition: multi-cursor insert mode
Action: press escape
Current result: change to multi-cursor normal mode

Desired result: change to single-cursor insert mode

seems like the vim behavior of esc moving from insert to normal mode would supersede the more vs code behavior of esc dropping out of multi-cursor to single-cursor mode

maybe shift-esc would accomplish that? similar to paradigm of a and A, w and W` which result in a stronger form of the action?

@quezak
Copy link

quezak commented Sep 13, 2019

@ralphcallaway are you talking about the Add Cursors to Line Ends hotkey? (it's shift-alt-i on my Linux) For me it works almost normally (adds the cursors as you said, then there's some vim error, but if I press esc it goes back to normal mode with the curors still at line ends). That takes care of your point 2 (point 1 is just plain selection). Alternatively, you can place the cursor on the first/last line, and use ctrl-shift-down/up to add another above/below. Note that if you used the selection method, you'll be in visual multi-cursor mode, so you need to press esc to go back to normal multi-cursor mode before point 3.

  1. I'm confused, on which platform does super-left do that? With the multiple curors in normal mode, you can thoughuse the plain old home button to go to line beginning. Or, using the vim way, press 0 to go to line beginning (or ^ to go to the first character in line).

4., 5. Still in normal mode, press v to go to visual multi-cursor mode, then just use the right key to select what you need. You can also use w in visual mode to select one word, t, to select until a comma, etc -- all vim motions work here.

  1. delete should work normally, or, the vim way, use d to cut the selection from visual mode (it can be even pasted in a different place, each cursor has its own clipboard).

@ralphcallaway
Copy link

@ralphcallaway are you talking about the Add Cursors to Line Ends hotkey? (it's shift-alt-i on my Linux) For me it works almost normally (adds the cursors as you said, then there's some vim error, but if I press esc it goes back to normal mode with the curors still at line ends). That takes care of your point 2 (point 1 is just plain selection). Alternatively, you can place the cursor on the first/last line, and use ctrl-shift-down/up to add another above/below. Note that if you used the selection method, you'll be in visual multi-cursor mode, so you need to press esc to go back to normal multi-cursor mode before point 3.

1. I'm confused, on which platform does `super-left` do that? With the multiple curors in normal mode, you can thoughuse the plain old `home` button to go to line beginning. Or, using the vim way, press `0` to go to line beginning (or `^` to go to the first character in line).

4., 5. Still in normal mode, press v to go to visual multi-cursor mode, then just use the right key to select what you need. You can also use w in visual mode to select one word, t, to select until a comma, etc -- all vim motions work here.

1. `delete` should work normally, or, the vim way, use `d` to cut the selection from visual mode (it can be even pasted in a different place, each cursor has its own clipboard).

@quezak that was exactly what i was looking for, thanks so much. super-left is a mac os x system convention, should have specified ...

now i realize i can search for "cursor" in the command palette and then use the keyboard shortcuts menu to track down the relevant hot key. ready to rock! thank you!!

@karlhorky
Copy link
Contributor

karlhorky commented Sep 29, 2019

@J-Fields I would also recommend taking a look at the issues reported here if you haven't already, there's a lot of things that should probably be issues under the area/multicursor label.

The poor integration with core VSCode features like multiple cursors is what is keeping me currently on amVim, although I would really like to switch back to mainline VSCodeVim.

@jdshaeffer
Copy link

I feel dumb but while editing some HTML, I somehow entered Multi-Cursor mode on accident, and I can't get out of it when I'm directly on an HTML tag. I get two cursors. One where I'm currently at and the other cursor goes to the same char in the matching tag. I'm not in Multi-Cursor mode once I hover over something that's not an HTML tag. How can I escape this madness

@J-Fields
Copy link
Member

@jdshaeffer html.mirrorCursorOnMatchingTag - added in VSCode 1.41

@jhobz
Copy link

jhobz commented Dec 19, 2019

@J-Fields That was driving me nuts and causing vim errors when I tried to use line selection mode while hovering a tag. Thank you for helping me find the root cause.

@Christopher-Hayes
Copy link

@J-Fields This is causing me a headache. I apparently somehow mistakenly turned on multi-cursors and they only show up on mirrored tags, nowhere else. If I click in for example an unmatched img tag, I can edit in Vim np. If I move my cursor to a tag that has a match, the mode goes from -- NORMAL -- to -- NORMAL -- MULTI CURSOR. Trying to work in HTML made VS Code completely unusable. Hitting escape does nothing, restarting VS Code does nothing, it just goes back to multi cursor mode. I have no idea how to turn this off. Only just fixed it, disabling html.mirrorCursorOnMatchingTag.

@J-Fields
Copy link
Member

J-Fields commented Jan 8, 2020

@Christopher-Hayes Yeah, it's annoying. I suppose we could check that setting and warn the user if they have it enabled, but I'm not sure how to actually fix this. Open to suggestions or PRs.

@Christopher-Hayes
Copy link

@J-Fields If there there is a way to log VSCodeVim's behavior, I would be willing to supply that if it helps. It consistently starts in MultiCursor mode on my end though. Honestly, I think this multiple cursors should be disabled by default. If someone wants multiple cursors, they're already going to have to hunt down the documentation first, so adding toggling that Setting to the list isn't a whole lot extra. On my end, I love VSCodeVim, I just want to keep using it as it is without worrying about new updates making it unusable.

@alac1984
Copy link

alac1984 commented Jan 22, 2020

Being more specific to people that doesn't get it like myself at first sight: if you're using this extension and suddenly a new cursor appeared everytime you put the cursor on a HTML tag (like @jdshaeffer and @jhobz explained above), it is because a new config in VSCode that was added in 1.41 version: html.mirrorCursorOnMatchingTag.

To remove this behavior, go to your settings.json file and include this line:

"html.mirrorCursorOnMatchingTag": false,

@trkoch
Copy link
Contributor

trkoch commented Feb 15, 2020

Is there a way do restore original behavior of <cmd-d> when in insert mode? Already tried <M-d>: false in vim.handleKeys and customizing keybindings (adding check for mode).

@karlhorky
Copy link
Contributor

restore original behavior of <cmd-d>

Big 👍 from me on getting this support!

Normal VS Code shortcut behavior would be something that would make me consider switching back from amVim (amVim integrates more correctly).

@J-Fields
Copy link
Member

@trkoch @karlhorky Try <D-d>, not <M-d>

@narze
Copy link

narze commented Jun 2, 2020

Is there a way do restore original behavior of <cmd-d> when in insert mode? Already tried <M-d>: false in vim.handleKeys and customizing keybindings (adding check for mode).

I keep checking out VSCodeVim for years, but this issue is not fixed and I have to go back to AmVim every time. I always use Cmd+d instead of gb.

The bug I found with this extension is when I use Cmd+d (in normal mode) it will work for some of the time, but when I switch to insert mode once, The multi-select cursors from next Cmd+d will have only 2 selections and cannot select more text. I found that to fix this I have to go to normal mode and press gb once, then Cmd+d will work until I go to insert mode again.

giphy

@trkoch @karlhorky Try <D-d>, not <M-d>

I tried both, not working

@kydonian
Copy link

kydonian commented Jul 1, 2020

One issue I've noticed:

Set up:

  • Enter multi-cursor mode
  • yw to yank the current word
  • move cursor(s)
  • p to past the word

current behavior:

  • pastes all words on successive lines beneath one cursor only

desired behavior:

  • pastes each word in its respective cursor location

@alirezanet
Copy link

alirezanet commented Jul 11, 2020

Is that possible to use VsCode multi cursor in INSERT mode? it's so much easier but not working after enabling vim extension.
I want to add cursor using (CTRL+ALT+UP) or (CTRL+ALT+DOWN). also useCtrlKeys is off "vim.useCtrlKeys": false,
any idea how to make this work again?

@alirezanet
Copy link

Is that possible to use VsCode multi cursor in INSERT mode? it's so much easier but not working after enabling vim extension.
I want to add cursor using (CTRL+ALT+UP) or (CTRL+ALT+DOWN). also useCtrlKeys is off "vim.useCtrlKeys": false,
any idea how to make this work again?

NVM. solved. just added these two to my keyboard shortcuts:

   {
        "key": "ctrl+alt+up",
        "command": "-extension.vim_cmd+alt+up",
        "when": "editorTextFocus && vim.active && !inDebugRepl"
    },
    {
        "key": "ctrl+alt+down",
        "command": "-extension.vim_cmd+alt+down",
        "when": "editorTextFocus && vim.active && !inDebugRepl"
    },

@oha-kialo
Copy link

The bug I found with this extension is when I use Cmd+d (in normal mode) it will work for some of the time, but when I switch to insert mode once, The multi-select cursors from next Cmd+d will have only 2 selections and cannot select more text. I found that to fix this I have to go to normal mode and press gb once, then Cmd+d will work until I go to insert mode again.

@narze, I was seeing exactly the same thing. A a work around though, if I first highlight the word though and then start pressing Ctrl+d, it seems to work perfectly.

@studgeek
Copy link

Is there a reason cmd+alt+up/down do not have vim.use in their when clause so they can be turned off using vim.handleKeys?

@nathancy
Copy link

I've implemented a solution to emulate terryma/vim-multiple-cursors in VSCode. See the solution in this thread!

4

@anon-legion
Copy link

Why is ctrl+d not working for me? When I type ctrl+d it jumps to the middle of the current visible lines of code

@Ngdaz
Copy link

Ngdaz commented Jul 10, 2023

Why is ctrl+d not working for me? When I type ctrl+d it jumps to the middle of the current visible lines of code

Because in Vim Ctrl + d and Ctrl + u are moving down, up half of the screen. Just mapping another shortcut for it in settings.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests