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

Keymapping with keys/commands after <Plug>(VM-*) doesn't work due to the hlsearch delay #231

Open
IndianBoy42 opened this issue Mar 15, 2023 · 1 comment

Comments

@IndianBoy42
Copy link

    Sorry for using lua but i thought I could do this:
      local map = vim.keymap.set
      map("x", "I", "<Plug>(VM-Visual-Cursors)I", { remap = true })
      map("x", "A", "<Plug>(VM-Visual-Cursors)A", { remap = true })

If I manually activate visual cursors then hit I then obviously it works
But when I try to use the remap it inserts <Plug>(VM-Hls) where the cursor enters insert mode

Originally posted by @IndianBoy42 in https://github.com/mg979/vim-visual-multi/discussions/229

@alextricity25
Copy link

For anyone wondering how to get around this issue, a slight delay can be added like so:

local function visual_cursors_with_delay()
  -- Execute the vm-visual-cursors command.
  vim.cmd('silent! execute "normal! \\<Plug>(VM-Visual-Cursors)"')
  -- Introduce delay via VimScript's 'sleep' (set to 500 milliseconds here).
  vim.cmd('sleep 500m')
  -- Press 'A' in normal mode after the delay.
  vim.cmd('silent! execute "normal! A"')
end

-- visual-multi
wk.register({
  m = {
    name = "Visual Multi",
    e = { visual_cursors_with_delay, "Visual Cursors", mode = { "v" } },
  }
}, { prefix = "<leader>" })

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

No branches or pull requests

2 participants