-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add ToggleSameIds #943
Add ToggleSameIds #943
Conversation
@idawes I'm interested in addressing the "doesn't behave nicely with large files" that you describe. How big of a file are you working with when you see problems? |
Perhaps this is something that I've got misconfigured. I'm using neovim in the terminal, and when I scroll the file using the mouse, the cursor stays on its current line until it hits the top (or bottom) of the screen, then moves down (or up) x lines (the mouse scroll distance) to stay in the visible portion of the file. When this happens, auto_sameids causes the highlighted selection to change. This isn't particularly surprising behaviour, given that it is just highlighting instances of whatever identifier is under the current cursor position. It is however undesirable, because I want to be able to see instances of the original highlighted identifier throughout the entire file, not just within one screen. After submitting this PR, I've actually found that it works better for me to just bind gs to :GoSameIds, and add :GoSameIdsClear to my C-l (clear highlight) binding. That way I can highlight all instances of an identifier throughout a file, then move to another identifier and highlight those without first having to toggle off the highlighting. |
That sounds like another way to address the issue for sure. I think I'll likely stick with turning off auto sameids and manually triggering sameids on and off though, as that currently fits with how I think about the functionality. I don't mind if you close this pr. |
I'm also experiencing the same as @idawes. And it's ok because the fix is not possible with current 7.4. I'm using it also for the past week so I have some ideas. My idea to fix it and going forward with vim 8.0 is the following (@bhcleek also shares the same idea as I see)
With vim 8.0 we're going implement a Job based call. Right now the implementation in What do you think? Does the above makes sense ? |
That's essentially what I was doing with this PR... I the toggle command bound to gs, so typing that once turned on the highlighting, and typing it again turned it off. I found that it was annoying if I had one thing highlighted and wanted to highlight something else. I had to type it 2 times, once to turn it off and once to start highlighting the new thing. Now I just have gs bound to GoSameIds, and I call GoSameIdsClear with Ctrl-l. This means that I can turn highlighting on, then move to a new identifier and highlight that, and when I want to clear the highlighting it's the same as clearing the highlighting for a search. I find this is working really well for me, so I'd prefer if GoSameIds didn't change behaviour. If you want the behaviour you're talking about @fatih, I'd suggest merging this PR and binding to that instead. |
This PR doesn't automatically enables it. It just highlights for the current cursor. When you move your cursor it doesn't do anything. I the approach I've described is useful and makes sense going forward. |
Oh right... sorry... missed that you were looking to change it to toggle auto-highlighting. If you do change the behaviour of GoSameIds, would you consider adding another function to trigger highlighting of the current identifier without enabling auto-highlighting? |
@fatih are you suggesting that |
Auto sameIds is cool, but it doesn't behave nicely in large files, where scolling the screen causes the cursor to move and therefore change the identifier that's being matched. This change allows me to quickly turn on and off same-id highlighting, and have the highlighting stay in effect as I scroll through the file.