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

motions don't effect multi cursors when vim-remotions is installed. #280

Open
eyalk11 opened this issue Oct 4, 2024 · 10 comments
Open

motions don't effect multi cursors when vim-remotions is installed. #280

eyalk11 opened this issue Oct 4, 2024 · 10 comments

Comments

@eyalk11
Copy link

eyalk11 commented Oct 4, 2024

Describe the issue:
motions doesn't effect multi cursors in normal mode.

They only work on the current single one
I have tried \\space and it seems to do nothing.
Why the its status is not shown in \\l ?

Steps to reproduce

  1. just enter normal mode and do a motion (like l)

I guess it is related to my configuration but have no idea how to debug

@eyalk11 eyalk11 changed the title motions doesn't effect multi selections motions doesn't effect multi cursors Oct 4, 2024
@eyalk11 eyalk11 changed the title motions doesn't effect multi cursors motions don't effect multi cursors Oct 5, 2024
@eyalk11 eyalk11 changed the title motions don't effect multi cursors motions don't effect multi cursors when repmo plugins is installed. Oct 8, 2024
@eyalk11 eyalk11 changed the title motions don't effect multi cursors when repmo plugins is installed. motions don't effect multi cursors when vds2212/vim-remotions is installed. Oct 8, 2024
@eyalk11
Copy link
Author

eyalk11 commented Oct 8, 2024

My suspicions were right. vds2212/vim-remotions plugin was the culprit . It doesn't work iff I load it.

@eyalk11 eyalk11 changed the title motions don't effect multi cursors when vds2212/vim-remotions is installed. motions don't effect multi cursors when vim-remotions is installed. Oct 8, 2024
@eyalk11
Copy link
Author

eyalk11 commented Oct 8, 2024

Probably similar to this : jinh0/eyeliner.nvim#59

@vds2212
Copy link

vds2212 commented Oct 9, 2024

Thanks for reporting this problem. I'll try to reproduce it on my side. I'll let you know.

@vds2212
Copy link

vds2212 commented Oct 9, 2024

Here is the problem I have reproduced:

If you register the h and l motions with vim-remotions:

let g:remotions_motions = {
      \ 'TtFf' : {},
      \ 'char' : {
      \    'backward' : 'h',
      \    'forward' : 'l',
      \    'repeat_if_count' : 1,
      \ },

When you are using vim-visual-multi when you are using these motion in multi cursor mode:

  • the cursor only move for the current word/cursor and not for all the cursors
  • when inserting text after the user (e.g. using the a operator) the text is insert like if the cursor has not been moved.

I believe the reason is that [vim-visual-multi] hijack the motions (i.e. introduces their own mapping for h and l) and these mapping get confused with the mapping for h and l that vim-remotions introduced.

I there is a solution I supposed it is in vim-visual-multi.

I had a look at the code but it seems rather complex.

Remark: If you don't have vim-remotions remapping h and l it seems to work fine with vim-visual-multi.

@eyalk11
Copy link
Author

eyalk11 commented Oct 9, 2024

You can check if the current state is normal visual-multi-cursors , just return the original key. I don't know if there is a local buffer variable for it.
I think your plugin take precedence . So if it does, it should handle these cases.
Making vim work good is constant pain , balancing all plugins with their respective bugs. There are so much hacks and competing resources.

@vds2212
Copy link

vds2212 commented Oct 10, 2024

vim-remotions is not aware that vim-visual-multi is on so it can adapt.

I believe that vim-visual-multi introduces a general mapping where vim-remotions introduces <buffer> mapping that overtake (win over the vim-visual-multi mapping) the vim-visual-multi mapping which is the cause of the problem.

A solution could be that:

  • vim-visual-multi make use of <buffer> mapping instead of global mapping
  • vim-visual-multi restore the mappings it override instead of just deleting the mapping it has introduced

@eyalk11
Copy link
Author

eyalk11 commented Oct 11, 2024

I do agree that seems like a good solution. Do visual multi has a reason to use global mappings?

@vds2212
Copy link

vds2212 commented Oct 11, 2024

I don't see any. The <buffer> mapping feature is already supported with vim 7.0.

@eyalk11
Copy link
Author

eyalk11 commented Oct 15, 2024

@mg979 ? If you are still maintaning it.

@vds2212
Copy link

vds2212 commented Oct 17, 2024

I had a closer look. It seems that vim-visual-multi already create <buffer> mapping for the motions but doesn't override existing <buffer> mapping for motions.
A solution would be to let vim-visual-multi the override the <buffer> mapping but to restore them when it leaves the multi-cursor mode.

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