brenton-leighton / multiple-cursors.nvim

A multi-cursor plugin for Neovim that works in normal, insert/replace, or visual modes, and with almost every command

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

After entering mouse mode and clicking on different places, cursors shows up and I can write things but I cannot delete it again, only on the initial line

leet0rz opened this issue · comments

So after adding multiple cursors in different spots with the mouse I can write things but I cant delete things if I make mistakes while typing, it will only delete on the very first line and the rest will stay as they are. Is this intended or is this a bug? Thanks, been looking for a plugin like this :)

So you add text while in insert mode, but you can't delete it with backspace, is that correct? Do Delete, Enter, and Tab work? Can you try disabling any other other plugins to see if that's the problem? What keyboard layout do you have?

So you add text while in insert mode, but you can't delete it with backspace, is that correct? Do Delete, Enter, and Tab work? Can you try disabling any other other plugins to see if that's the problem? What keyboard layout do you have?

Yes, backspace is not working as it is suppose to, it only cleans out where the initial cursor is but none of the other locations do anything.

Delete, tab and enter works fine. Keyboard is qwerty.

I have just tried to disable a bunch of plugins, does not seem to do anything. I only have like 20 plugins to begin with. Maybe a remap is messing with it. Not sure. Can you think of anything that might interfere that you've coded into this?

I think either remapping the key isn't working, or something in your options is causing the backspace function to fail (maybe something to do with indentation/tabbing). Could you try the plugin with no custom options set?

You could also try adding something like vim.print("hello") to the backspace function to see if it's actually being called. The function is named virtual_cursor_insert_mode_backspace on line 119 of insert_mode.lua.

I think either remapping the key isn't working, or something in your options is causing the backspace function to fail (maybe something to do with indentation/tabbing). Could you try the plugin with no custom options set?

You could also try adding something like vim.print("hello") to the backspace function to see if it's actually being called. The function is named virtual_cursor_insert_mode_backspace on line 119 of insert_mode.lua.

Tried commenting out all my remaps and global settings, no luck either. Still happening. Tried different shells too but same deal.

I added the print statement just below the function on the first line there so at line 120 but it does not seem to appear when I open nvim.

The print would happen every time you press backspace in insert mode, and once for each extra cursor. Does that happen?

The print would happen every time you press backspace in insert mode, and once for each extra cursor. Does that happen?

No prints happening.

Does backspace work in normal or replace modes?

Could you try executing this before creating a new cursor, and also while multiple cursors are active:

:lua vim.print(vim.inspect(vim.fn.maparg("<Backspace>", "i", false, false)))

In the first case I get "", and then while multiple cursors are active I get:

"<Lua 261: ~/.local/share/nvim/lazy/multiple-cursors.nvim/lua/multiple-cursors/insert_mode.lua:191>"

I get this on both: v:lua.mpairs.autopairs_bs()

I tried to disable autopairs and now backspace seems to work, I am pretty sure I disabled it last time and it still did not work. Strange. Are you able to make them both coexist? A lot of people use autopairs for a lot of things.

Other than that when trying to go into normal mode and performing actions there like change word and such it does not work, is this intended?

Thanks :)

I tried to disable autopairs and now backspace seems to work, I am pretty sure I disabled it last time and it still did not work. Strange Are you able to make them both coexist? A lot of people use autopairs for a lot of things.

This plugin should just take over the mapping when multiple cursors are created, and then restore the mapping when clearing the extra cursors. I'm not sure why it's not doing that, I could look at it in the future.

I think there are two options currently:

  1. Disable autopairs while using multiple cursors. You would provide a function that disables autopairs as the pre_hook option, and another function that enables autopairs as the post_hook option.
  2. Add a mapping to custom_key_maps to call the autopairs backspace function, but I'm not sure if this will actually work with multiple cursors.

Other than that when trying to go into normal mode and performing actions there like change word and such it does not work, is this intended?

Operator pending commands like c in normal mode aren't currently implemented, but it's probably the next thing I'll look at.

I've looked at windwp/nvim-autopairs and there's two problems:

  • It creates key mappings on the InsertEnter event
  • The key mappings it creates can't be changed (with the exception of CR for some reason)

The only thing I can suggest is to use mini.pairs instead. That at least can be disabled while multiple cursors is active, like so:

opts = {
  pre_hook = function()
    vim.g.minipairs_disable = true
  end,
  post_hook = function()
    vim.g.minipairs_disable = false
  end,
}

I've tried using the functions from mini.pairs but they don't seem to work when called directly, so it just has to be disabled.

I've looked at windwp/nvim-autopairs and there's two problems:

* It creates key mappings on the InsertEnter event

* The key mappings it creates can't be changed (with the exception of CR for some reason)

The only thing I can suggest is to use mini.pairs instead. That at least can be disabled while multiple cursors is active, like so:

opts = {
  pre_hook = function()
    vim.g.minipairs_disable = true
  end,
  post_hook = function()
    vim.g.minipairs_disable = false
  end,
}

I've tried using the functions from mini.pairs but they don't seem to work when called directly, so it just has to be disabled.

Would just creating remaps for lets say ( to type ()<left> fix the problem? Instead of using autopairs or minipairs.

Would just creating remaps for lets say ( to type ()<left> fix the problem? Instead of using autopairs or minipairs.

Yeah that would work if that's the behaviour you want. I think the plugins would also check to see if the closing character already exists.

You could do something like this:

custom_key_maps = {
  {"i", "(", function()
    vim.api.nvim_put({"("}, "c", false, false)  -- Put a "(" before the cursor without moving the cursor
    vim.api.nvim_put({")"}, "c", true, false)   -- Put a ")" after the cursor without moving the cursor
  end},
}

I realised I did something incorrectly when setting key maps. multiple-cursors.nvim was setting global key maps, but backspace in insert mode set by nvim-autopairs was a local buffer key map. I've changed multiple-cursors.nvim to use only local buffer key maps, and it can now work fine alongside nvim-autopairs if you disable it while using multiple cursors.