element-based navigation
What command or commands
Add a new mode to navigate elements on a page, not unlike arrow keys on duckduckgo.
How should a feature do
When a user has done such steps:
- Go to a URL with vertically placed items, e.g. https://github.com/gdh1995/vimium-c/issues
- Press a key (maybe
c?) - Start pressing arrow-like keys (down / up, j / k)
then Vimium C should do:
- Highlight, scroll to the right element, and focus its link to open if desired.
The user should also be able to exit this mode again.
I made something like this here (not tested as well with SPAs).
You may use LinkHints.click to switch focus among some elements.
For example, on a Google search result page, this will switch focus among search result items:
map xxx LinkHints.click mode="focus" match="a:has(h3)" directOptions={"offset":"cur","search":"doc","loop":1}
# then `xxx` will go down and `-xxx` will go up
Note: loop in directOptions requires Vimium C v2.0+ .
that's pretty cool! i hadn't realized vimium already offered things like this.
i feel that approach may still pose a barrier to casual users though, as it both requires a basic understanding of CSS selectors, while selectors like a:has(h3) are also circumstantial, making them harder to reuse across a wider range of web pages.
i'll admit the attempt i made also wasn't really perfect yet. but it'd be nice to see more general approaches explored here as well.
Yes a:has(h3) is too exact to reuse - it may not work on other websites.
You may use env to bind one key to multiple commands, like:
- an example is https://github.com/gdh1995/vimium-c/issues/1132#issuecomment-2135856990
- the syntax is https://github.com/gdh1995/vimium-c/wiki/Map-a-key-to-different-commands-on-different-websites
As for CSS knowledge, because Vimium C is designed to "advanced computer users" (especially programmers), it would not block Vimium C users, I guess.