Search in block of code
Answered
Hi!
Sometimes I work with function libraries that have very large functions. Occasionally I want to look for a keyword just in that function that I'm currently in with my marker. Is there a way to search just in a specific block of code, like the function you are in, or the scope, the class or whatever?
Please sign in to leave a comment.
Hi there,
As far as I understand your situation -- not really.
For any text search (e.g. in current file only -- "Edit | Find | Find") you can limit only to comments/strings/literals (look under cog icon for options when Find bar is visible). You may try on page Replacement instead of Find -- it can limit to Selection only .. but it's not so convenient (I mean -- be careful to not to make actual replacement; plus, because of actual selection .. it might be hard to see the actual occurrences (but this should depend on color schema used)).
For search across multiple files you may use path, file extensions or custom scope (a set of files and folders that match your filter criteria) .. but that's not what you are doing here...
If the element you are looking for is not "any text" but specific identifier (variable/field/etc) .. then you may try Find Usages family of actions (multiple options under "Edit | Find") -- for local variable it should find occurrences in appropriate scope only (e.g. for a local variable defined in one function it should not be looking for the same named variables from another function).
Hello,
Andriy is right - there is no straight way to do this.
We already have a related request submitted to our tracker here: <https://youtrack.jetbrains.com/issue/IDEA-138365>. Please vote for it in order to move it up in the queue and receive notifications regarding the progress of the issue. See more information on working with tracker at <https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications>.
Thank you. Using the search tool the way Bazanov described helps a bit with my situation. I will vote for the issue though ;)
Hi,
Please implement this feature as it will be very handy.
Thank you