Vimium: Feature Request: Search (/) starts from current window?

Created on 25 Sep 2016  路  2Comments  路  Source: philc/vimium

Currently search in viminum starts from beginning or last stopped position. This is a little annoy because there is no cursor which is always in current visible Window like Vim. Make search (both / and ?) beginning from current visible windows will be very helpful for context based search.

Most helpful comment

This is supported in VimFx. Just thought I'd pitch in with how VimFx deals with it, in case it is of any help.

Firefox searches from the current selection in the page, or from the top of the page if there is none. So what VimFx basically does is:

if selection in page:
  if selection on screen:
    return // Let the search go from there.
  else:
    clear selection

find first text in the viewport
make a selection there
return // let the search go from there.

Here's most of the logic:

https://github.com/akhodakivskiy/VimFx/blob/168021b756ce4d7cece363a46dc2419e3e74bd55/extension/lib/commands-frame.coffee#L546-L589

And here are most of the really tricky helper functions used defined:

https://github.com/akhodakivskiy/VimFx/blob/168021b756ce4d7cece363a46dc2419e3e74bd55/extension/lib/viewport.coffee

A few tricky things:

  • Performance.
  • position: fixed; elements.
  • Actually finding the first text in the viewport.
  • Firefox supports multiple selections, possibly even in different frames!

All 2 comments

This is supported in VimFx. Just thought I'd pitch in with how VimFx deals with it, in case it is of any help.

Firefox searches from the current selection in the page, or from the top of the page if there is none. So what VimFx basically does is:

if selection in page:
  if selection on screen:
    return // Let the search go from there.
  else:
    clear selection

find first text in the viewport
make a selection there
return // let the search go from there.

Here's most of the logic:

https://github.com/akhodakivskiy/VimFx/blob/168021b756ce4d7cece363a46dc2419e3e74bd55/extension/lib/commands-frame.coffee#L546-L589

And here are most of the really tricky helper functions used defined:

https://github.com/akhodakivskiy/VimFx/blob/168021b756ce4d7cece363a46dc2419e3e74bd55/extension/lib/viewport.coffee

A few tricky things:

  • Performance.
  • position: fixed; elements.
  • Actually finding the first text in the viewport.
  • Firefox supports multiple selections, possibly even in different frames!

One fix for this might be to hit v to lay down and position a cursor. Then use / to make your search? It's not perfect but it is better than nothing. v will typically place your cursor at the top of current visible window.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

PickRelated picture PickRelated  路  4Comments

bartlibert picture bartlibert  路  4Comments

Poseiden picture Poseiden  路  3Comments

peter099 picture peter099  路  3Comments

lawiparadise picture lawiparadise  路  3Comments