Searching Code with RubyMine's Usage Search

April 21, 2013 Jared Carroll

When browsing a codebase, you often want to view the definition of a particular class, method, or variable. However, sometimes you want to do the reverse; you want to see where a particular class, method, or variable is used. Typically this involves using your editor’s text search, or a command line tool, such as grep or ack. Unfortunately, text searches may return false positives, such as log file data, or similarly named constructs. The problem is that you want to search code not text.

RubyMine has text search, but it also includes a powerful, code-based usage search. Usage search is smarter than text search, because RubyMine is aware of code constructs such as classes, methods, and variables. This results in a more accurate search; allowing you to quickly view and navigate actual usages. In this post, we’ll explore RubyMine’s usage search on OS X.

Find Usages

To find where a particular class, method, variable (instance or local), or parameter is used, place your cursor on it, and press alt/option + F7. Results will be displayed in the Find tool window.

find usages

command + alt/option + Up/Down navigates the results. Use F4 to jump to the source code of a particular usage.

Recent usage search results can be viewed again with command + E.

recent usages

Find Usages in File

By default, find usages is scoped to the entire project. To scope it to the current file, use command + F7. command + G and command + shift + G navigate the results.

Show Usages

command + alt/option + F7 can be used to show usages inline. Instead of displaying usages in the Find tool window, they appear in a pop-up window.

show usages

Searching Code

RubyMine’s usage search demonstrates an advantage an IDE has over a text editor. By being aware of code constructs, such as classes, methods, and variables, IDEs can offer powerful tools that allow you to quickly and accurately explore a codebase.

About the Author

Biography

More Content by Jared Carroll
Previous
Filling the App Gap: The Challenges of Moving Forward with Cost-Effective App Development
Filling the App Gap: The Challenges of Moving Forward with Cost-Effective App Development

James Quigley’s recent Wired article describes the difficulty companies are having in finding their way tow...

Next
Corporate App Stores Bring Many Benefits
Corporate App Stores Bring Many Benefits

If you’re not deploying as many apps as you would like as fast as you would like, you might think about how...

Enter curious. Exit smarter.

Register Now