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

Can you add / search for text and jump to links like Vimium does #84

Open
nikitavoloboev opened this issue Jan 10, 2018 · 11 comments
Open

Comments

@nikitavoloboev
Copy link

It would be really amazing if you could press / key and a vim like search prompt opens. Jumping to a text that is a hyperlink will then let you press return on it to go to the link.

Vimium does it this way and its really useful. Is this possible to do in sVim? I am willing to try and add this feature if it is possible. Thank you.

@luchenyuxx
Copy link
Contributor

It's absolutely possible in sVim. Feel free to implement it.
I will also try it on my side.

@nikitavoloboev
Copy link
Author

Hey @luchenyuxx

Just wanted to ask if there was any update on this feature. 🙂

I looked at sVim code and don't even know where to start adding support for this. 😞

@luchenyuxx
Copy link
Contributor

Hello @nikitavoloboev,
I was working on another feature recently (you can check my pull request).
To start, you can check the file sVimTab.js, this file is loaded when a page is loaded. There is a command list there. Add your new command there.
Another file is sVimGlobal.js. The default key binding is defined there.
Use safari extension builder to load the project into safari.

@nikitavoloboev
Copy link
Author

nikitavoloboev commented Feb 6, 2018

Hey @luchenyuxx

Did you by chance have any time to look at this?

I can understand how I can map / to do the searching but. But I also want it to allow users to go to link all from keyboard by pressing enter if the selected text is a link just like Vimium does.

@nikitavoloboev
Copy link
Author

Hey @luchenyuxx. Can you guide me on how I can make this change. This is literally the only thing I wish existed in sVim that it currently doesn't do. 😞

Thank you.

@luchenyuxx
Copy link
Contributor

@nikitavoloboev Sorry for the late response. Sure, I can try to write a Contributing.md.
Generally speaking, the codes loaded once are in sVimGlobal.html, and for every tab opened, the codes in sVimTab.js are executed. You can start from this. You can use Safari extension builder to build and load this project.

@pysnow530
Copy link

A great feature!👍

@rtgoodwin
Copy link

@nikitavoloboev did you end up with working code for / searching? I was deep diving into safari but can't seem to find a way to trigger it. I'd settle for it just triggering the native Find in page, but if you did something a bit better like Vimium I'd love to know. :)

Thanks!

@flyingotter17
Copy link

I just switched back to safari, from Firefox, which I switched to from Chrome, where I first started using Vimium and I must say that /search is the most essential part of Vimium. I am going to try to implement this myself though I have no real clue where to start, but the trial and error is half the fun. :) If anyone has successfully implemented this, it would deeply appreciated if you could post the code here for reference!

@odnoletkov
Copy link

odnoletkov commented Aug 8, 2019

BTW in Vimium there is even more advanced feature for this – filtered hints. Instead of using full-text search to target links (which is sometimes inconvinient because it would hit non-links text as well) it changes the way link navigation mode (f key) operates. Instead of adding arbitrary labels to links it uses link's text itself to filter and navigate to target link.

Firefox has a similar feature built-in – called 'Quick Find Link' (' key)

Now that is a feature I would absolutely love to have in sVim as well. I find it the best option for mouseless links navigation.

@shaunlebron
Copy link

shaunlebron commented Sep 29, 2020

For those who care, I found a minimal way to do this without sVim:

  1. Use Cmd+F to find and highlight the link (Enter to cycle).
  2. Press Esc to exit the search box.
  3. Press Esc again to “focus” the link (requires the setup below).
  4. Use the native Enter or Cmd+Enter to open it.

To make Step 3 work, I use the PageExtender.app safari extension so that ~/.js/default.js is loaded in every page with the following code:

// Press Escape to focus a highlighted link
window.addEventListener('keypress', e => {
  if (e.key == "Escape") {
    const sel = window.getSelection()
    const node = sel?.anchorNode?.parentNode
    if (node?.tagName.toLowerCase() == 'a') {
      e.preventDefault()
      sel.removeAllRanges()
      node.focus()
    }
  }
})

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

7 participants