mg979 / vim-visual-multi

Multiple cursors plugin for vim/neovim
MIT License
4.28k stars 82 forks source link

Toggling on/off not working #225

Closed melhakim closed 1 year ago

melhakim commented 1 year ago

Describe the issue: \\<Space> does not toggle visual-multi

Steps to reproduce

  1. Start vim
  2. type \\<Space> (shortcut to toggle)
  3. Type <Shift-arrow(l/r)>, should not select. However vm still starts.

mg979 commented 1 year ago
  1. \\<Space> should add a single cursor, not toggle. That is Space.
  2. You can set g:VM_default_mappings to 0, then map only the plugs you want.
melhakim commented 1 year ago

Thanks for the quick response! According to the docs, \\<Space>, and \\\ is what adds a single cursor (and that works as expected).

I have tried manually mapping using:

:map \\<Space> <Plug>(VM-Toggle-Mappings)

hoewever I get the error:

E716: Key not present in Dictionary: "Maps.mappings_toggle()"

when I hit \\<Space> after that.

Looking at maps.vim, it seems that this function is supposed to do exactly that.


To elaborate on my issue, I don't want VM to map <S-Left> and <S-Right>, because I use them for their default motion. For now, I have disabled them using VM_maps. However that disables Select h and Select l during extended mode.

mg979 commented 1 year ago

According to the docs, \, and \\ is what adds a single cursor (and that works as expected).

Yes I forgot.

I have tried manually mapping using:

You should use the g:VM_maps dictionary. That cannot work because it's a buffer mapping that only exists when VM is enabled. It toggles VM mappings inside of VM, not outside of it.

let g:VM_maps["Toggle Mappings"]    = '\\<Space>'

To elaborate on my issue

let g:VM_default_mappings = 0

Then you manually map the plugs you want

<Plug>(Add-Cursor-Down)
<Plug>(Add-Cursor-Up)
<Plug>(Select-All)
<Plug>(Start-Regex-Search)
<Plug>(Add-Cursor-At-Pos)
<Plug>(Select-h)
<Plug>(Select-l)
melhakim commented 1 year ago
let g:VM_maps["Toggle Mappings"]    = '\\<Space>'

I tried that but it doesn't change anything. It looks like this functionality is not accessible from outside the script somehow. I might be misunderstanding, but isn't this "Toggle Mappings" supposed to turn off all shortcuts for VM until it is pressed again?

mg979 commented 1 year ago

I just tried it and it works. What script are you talking about?

It is meant to remove all VM buffer mappings, while staying in VM, so that for example you can move the main cursor without moving all cursors, it's like some kind of 'pause VM'. You press it again to reapply buffer mappings. In the statusline (right corner) the first letter is M if mappings are enabled, m if disabled.

mg979 commented 1 year ago

It doesn't disable global VM mappings, if it's what you meant. It only works inside VM.

melhakim commented 1 year ago

It is meant to remove all VM buffer mappings, while staying in VM, so that for example you can move the main cursor without moving all cursors,

Alright, I suppose I misunderstood then. I'll stick to remapping using VM_maps. Thanks!