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

C-n jumps to the start of the next line first time it is used #243

Open
snikoletopoulos opened this issue Jun 29, 2023 · 11 comments
Open

C-n jumps to the start of the next line first time it is used #243

snikoletopoulos opened this issue Jun 29, 2023 · 11 comments

Comments

@snikoletopoulos
Copy link

snikoletopoulos commented Jun 29, 2023

Describe the issue:
I have the plugin installed with lazy.nvim and have it set up to not load lazily. When I type <C-n> instead of going to the next word the cursor jumps to the start of the next line. When I redo the steps it works normally

Steps to reproduce

  1. Go to a word
  2. <C-n>
  3. Cursor goes to the next line

  • Operating System: Mac OS 13.4
  • Vim Version: NVIM v0.9.0 Build type: Release
  • commit SHA/branch: latest
@mg979
Copy link
Owner

mg979 commented Jun 29, 2023

There was a similar issue, but I can't find it, try #241.

@snikoletopoulos
Copy link
Author

I tried :echo VM_maps["Find Under"] it says I don't have it (E716: Key not present in Dictionary: "Find Under")

@mg979
Copy link
Owner

mg979 commented Jul 2, 2023

When you start neovim, before starting VM for the first time, see what says

nmap <c-n>

@snikoletopoulos
Copy link
Author

No mapping found
If I disable the plugin the cursor goes to the next line every time

@mg979
Copy link
Owner

mg979 commented Jul 3, 2023

If I disable the plugin the cursor goes to the next line every time

Because it's the normal behaviour for c-n. I'm pretty sure it's an issue with the package manager and I don't know how to fix it. Try putting the plugin in pack/start or pack/opt then add it with packadd in your vimrc.

Also I don't understand how it can work the second time, since c-n isn't mapped.

BerkeleyTrue added a commit to BerkeleyTrue/dotfiles that referenced this issue Feb 16, 2024
Otherwise <C-n> will insert <CR> on first run, due to default mapping
occuring

see mg979/vim-visual-multi#243
@JoseConseco
Copy link

JoseConseco commented Feb 23, 2024

The above BerkeleyTrue/dotfiles@a3b4487 fixed issue for me. ( lazy=false) . I think issue can be closed.

@renxzen
Copy link

renxzen commented Feb 23, 2024

With Lazy.nvim, even with lazy=false i still face the same issue

{
    "mg979/vim-visual-multi",
    lazy = false,
},

@JoseConseco
Copy link

ok, you are right - visual mode still did not work. My workaround is to call vm in any way, so that its keys gets loaded:

  {
    "mg979/vim-visual-multi", --multi cursor 
    config = function()
      vim.g.VM_mouse_mappings = 1
      vim.cmd[[VMDebug]]  -- fixes the  ctrl+n in visuala mode
    end,
  },

@renxzen
Copy link

renxzen commented Feb 26, 2024

Above answer didn't solve it, but helped by showing me the overwritten imap error in the debug message from #172

Disabling windwp/nvim-autopairs made the problem completely go away so i modified the lazy config like this.
It definitely solved the issue.

	{
		"mg979/vim-visual-multi",
		init = function()
			vim.g.VM_maps = {
				["I BS"] = '',
			}
		end,
	},

@dpetka2001
Copy link

I posted my solution here which was inspired by the aggregation of the answers in this issue. Also, I didn't have to disable windwp/nvim-autopairs in my case.

@avario-cpu
Copy link

avario-cpu commented Dec 5, 2024

To fix compatibility with nvim autopairs:

config = function ()
    -- Hack around issue with conflicting insert mode <BS> mapping
    -- between this plugin and nvim-autopairs
    vim.api.nvim_create_autocmd("User", {
      pattern = "visual_multi_start",
      callback = function()
        pcall(vim.keymap.del, "i", "<BS>", { buffer = 0 })
      end,
    })
    vim.api.nvim_create_autocmd("User", {
      pattern = "visual_multi_exit",
      callback = function()
        require("nvim-autopairs").force_attach()
      end,
    })
end

To fix compatibilty with nvim treesitter-textobjects:

config = function ()
    -- Fixes conflict with treesitter-textobjects bindings
    vim.g.VM_maps = {
      ["Goto Next"] = "]v",  -- can be any bind
      ["Goto Prev"] = "[v",
    }
end

Presence of any of those 2 plugins without respective fix will have a newline added on VM startup afaik. Maybe there are more plugins with a similar comp. issue

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

6 participants