Searching Within a File in RubyMine

July 14, 2013 Jared Carroll

After opening a file, your next step is usually to search within that file for some text, or perhaps, a particular method. Like text editors, RubyMine supports simple text search. However, it also offers more powerful method and usage search. In this post, we’ll look at various ways to search within a file in RubyMine on OS X.

Text Search

Press command + F to search for text within the current file. Use command + G and command + shift + G to move forward and backward through the search results.

After selecting text, search for it with command + F.

After beginning a text search with command + F, press control + H to view recent searches.

recent-searches.png

Repeat the last text search by not entering a query into the search bar, and then pressing return.

Word Search

Enable quick word searching by adding a shortcut for the “Find Word at Caret” command. I map it to control + F3. If you use this mapping, then you may have to disable the OS X “Move focus to the the dock” shortcut.

Method Search

Use command + F12 to view the structure of the current file in a popup, then type the name of the method you’re looking for.

method-search.png

This is quicker and more accurate than using text search.

Usage Search

Find usages in the current file of the symbol under caret (e.g., a variable, method, or class) with command + F7. Use command + G and command + shift + G to move forward and backward through the usages.

Highlight usages in the current file of the symbol under caret with command + shift + F7. Use command + G and command + shift + G to move forward and backward through the usages.

highlight-usages-in-file.png

Press Esc to clear the highlighting.

Search for Code Not Text

By being aware of code, an IDE can allow you to search for a method, instead of performing a text search such as “def show”. Text search will always have its time and place, but use it as a last resort. Move on from old text editor habits and learn your IDE’s more powerful alternatives.

About the Author

Biography

More Content by Jared Carroll
Previous
Pivotal HD Community and Pivotal HD Single Node (VM) Available for Download Today
Pivotal HD Community and Pivotal HD Single Node (VM) Available for Download Today

Since the announcement of Pivotal HD & HAWQ on February 25th, we’ve been encouraged by the positive recepti...

Next
Testing Strong Parameters – Redux
Testing Strong Parameters – Redux

With the flurry of new features introduced in Rails 4 I was interested in how they would affect every day d...

Enter curious. Exit smarter.

Learn More