hop.nvim icon indicating copy to clipboard operation
hop.nvim copied to clipboard

Automatic HopChar1 while using HopChar2

Open joshuali925 opened this issue 3 years ago • 3 comments

I used Intellij easymotion and liked their behavior, wondering if this can be possible in hop.nvim:

  1. run HopChar2
  2. type one character
  3. hop highlights all matches with 1 or 2 characters hints, and none of the first character of the hints collides with a possible second character that user will type for HopChar2
  4. user can type hints to jump directly, or type the second character to narrow down the hints
  5. if user types the second character, hop refreshes hints and behaves like current HopChar2 with 2 characters typed

For example using the paragraph above, if user runs HopChar2 and types u, the letter u will be highlighted with hints, but none of the hints will start with n (run), s (user), m (jump), r (current). The benefit is that

  1. if there are not many matches, user can type hint directly
  2. user does not need to use char2_fallback_key like in #142
  3. if there are many matches, user can still narrow down like how HopChar2 is behaving now

I've not looked deep into current implementation and I recognize non-trivial logic might be needed to support it. But still want to bring it up to see if this sounds interesting or if there are reasons against it. Thanks for your work.

joshuali925 avatar Aug 11 '22 04:08 joshuali925

This is exactly what lightspeed's shortcuts do. It's even better than what you described, because the remaining hints don't change when refreshing, so you don't have to pause after the first or second character. (The flip side is that this complicates the UI - differently styled hints are needed for the "shortcuts". In hindsight, I personally don't find this particular feature useful enough to justify the cost, but it's there.)

ggandor avatar Aug 11 '22 08:08 ggandor

Thinking about your specific proposal a bit more, I don't see much point in it - maybe I don't fully understand it. This just collapses 1-char mode and 2-char mode to one keymap, while even restricting the usable hints for 1-char mode, but achieves nothing else. It allows you to postpone your decision whether to use HopChar1 or HopChar2, but provides no further information to help that decision, so you could just as well decide beforehand.

if there are not many matches, user can type hint directly

This is the one that confuses me. As I understand, all 1-char matches would get hints after entering the first character anyway, and you could still reach any of them if you want, right? I mean, if you see that there is a multi-char hint for your target, then you would say "oh... I just switch to HopChar2 then", or what? You would have finished typing those two hint characters for HopChar1 already, instead of pausing.

ggandor avatar Aug 11 '22 09:08 ggandor

if you see that there is a multi-char hint for your target, then you would say "oh... I just switch to HopChar2 then"

It's mostly the opposite. HopChar2 would be used for most of cases, but in case of difficult-to-type second character or end of line, being able to postpone my decision (falling back to HopChar1 automatically) would help.

I understand your question of "why not decide beforehand", but it's just how my brain works. It would be easier for me to use 1 key to trigger a jump, instead of deciding whether I want HopChar1 or HopChar2 and think about which key triggers it.

With that being said, I looked a bit into lightspeed and the main issue is that the shortcuts feature does not highlight every match with jumpable hints after typing one character, some will still require user to type the second character. Now I lose the ability to postpone my decision if the second character is difficult to type.

I also see other problems with lightspeed that are not very relevant but would be issues (or takes time to get used to) for me personally, I think it's just how people have different thought processes/habits/muscle memories.

joshuali925 avatar Aug 12 '22 03:08 joshuali925