Sublime Forum

Binding keys in "Find Results" context

#1

I’d like to rebind keys in the “Find Results” window such that:

  • only the vertical movement keys are enabled, I don’t wander off to the right hand side
  • when I hit “Enter” I jump to the result I’ve navigated to, instead of using “F4”
  • for these changes to take place only in the context of the “Find Results” window

What context should I attempt to bind to to achieve this?

On a wishlist-y note, the “Find Results” shows some handy context, but it would be nice if

  • for “Find Results” only, the binding for “goto symbol” presented a dropdown list of only those exact lines containing a match without context
  • selecting something from that dropdown navigated to the file and line in question
0 Likes

#2
  • when I hit “Enter” I jump to the result I’ve navigated to, instead of using “F4”

You can use a package like BetterFindBuffer
https://packagecontrol.io/packages/BetterFindBuffer

It has a key binding on enter that allows you to use the enter to open the file (However, you’d want to use enter only on lines that have matches. The above key binding is a bit generic from the looks of it and navigates to any line & col position).

  • only the vertical movement keys are enabled, I don’t wander off to the right hand side

You’d need 2 custom key bindings for it.

{ "keys": ["left"], "command": "noop", "context": [{ "key": "selector", "operator": "equal", "operand": "text.find-in-files" }]
},
{ "keys": ["right"], "command": "noop", "context": [{ "key": "selector", "operator": "equal", "operand": "text.find-in-files" }]
},
  • for these changes to take place only in the context of the “Find Results” window

All of the key bindings in question are masked by a context that checks whether the view is in fact a Find Results view. Otherwise, it won’t work.

0 Likes

#3

Great pointers, thanks.

0 Likes