Search within open file #9984
Unanswered
Rylan12
asked this question in
Code Search and Navigation
Replies: 1 comment
-
I definitely want to implement this, but as you point out, it's not 100% clear what the best UX is to achieve this. I'm very interested in trying to figure it out, though. I'll update when some progress is made on this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've found myself wishing that there was an easy way to constrain a new search to the currently open file.
The biggest example is if I know a method is called somewhere in a long file but not necessarily which line. One way to find it is to do a new search and hope the file I want shows up toward the top (which, unless the method is also defined in that file, seems unlikely). I can, of course, add a
path:
search qualifier but this takes a lot of time.If I already have found an instance of this method, I can just click the symbol and view other references which is super cool, but if you don't know where on the page you're supposed to be looking, it's a bit tough. So, this tends to be a problem for methods that have common names and may appear tons of times in different contexts in a given repo.
My suggestion is to have a way to easily restrict a new search to the currently open file. I can think of a few ways this might intuitively work:
g
,G
, or a number though... could also be a keyboard shortcut to start typing a new searchpath:PATH
to the search when a file is currently openpath:PATH
.As an additional thing, it might be nice to have the box that appears when you select text say e.g. "Search for QUERY in this file, this repo, or all repos" and let you restrict the search to only the current file that way, too.
It's worth noting that you can of course use Command-F to do a normal search (which is how I would do this on GitHub.com) but it feels a little silly to have to use browser search on a code search website. Plus, my browser doesn't support regex searches
Beta Was this translation helpful? Give feedback.
All reactions