mg979 / vim-visual-multi

Multiple cursors plugin for vim/neovim
MIT License
4.13k stars 79 forks source link

Can't leave visual multi #220

Closed hcarver closed 1 year ago

hcarver commented 1 year ago

Describe the issue:

Can't leave visual-multi. Since updating to the latest version, and the latest version of vim, once I enter VM / Multi mode, using or fails to exit visual multi.

I'm afraid my vim understanding is not strong enough to debug this without help from you!

Steps to reproduce

  1. Move to some text, hit to make an initial selection
  2. Type (nothing happens, text still selected, still in visual multi mode)

This still happens with the minimal vimrc provided.


mg979 commented 1 year ago

Does it work with an older vim version?

hcarver commented 1 year ago

Does it work with an older vim version?

Yes! I narrowed it down to between 9.0.950 and 9.0.1000. I can leave the plugin on 9.0.0950 but I can't on 9.0.1000.

mg979 commented 1 year ago

See if it exits with a delay (press esc, wait some seconds), rather than not exiting at all.

Anyway you can try remapping the exit key

let g:VM_maps = {}
let g:VM_maps["Exit"] = '<C-c>'

Maybe it handles differently the esc key, my system vim version is lower (9.0.630 I think) and I can't test the new one atm.

hcarver commented 1 year ago

It doesn't exit with any delay - I waited about 30 seconds.

But remapping did work. With that change to the Exit key, C-c worked to quit VM mode.

mg979 commented 1 year ago

If anybody uses a vim version that exhibits this behavior, can try to change this line:

https://github.com/mg979/vim-visual-multi/blob/724bd53adfbaf32e129b001658b45d4c5c29ca1a/autoload/vm/maps.vim#L96

and also add

&& !has('patch-9.0.###')

Replace ### with the patch that introduced the different behavior of the esc key. I don't know what it is, but it should be between 9.0.950 and 9.0.1000, as @hcarver said here.

Could be 9.0.974 (vim/vim@dffa6ea85c82bbcb60368f38f7437c6cd89c9e55), so the new line would be:

if !has('nvim') && !has('gui_running') && !has('patch-9.0.974')

The same should be done here

https://github.com/mg979/vim-visual-multi/blob/724bd53adfbaf32e129b001658b45d4c5c29ca1a/autoload/vm/maps.vim#L132

mg979 commented 1 year ago

I gave it a try and it doesn't work. But it's a vim issue, if I do:

nnoremap <esc> o

it doesn't work. The key esc produces a different code now and <esc> isn't recognized anymore.

mg979 commented 1 year ago

Fixed by https://github.com/vim/vim/commit/32030a9f3be25e1343ef15028511614fb4c20e9f