Read more

RubyMine: Efficiently filtering results in the "Finder" overlay

Michael Leimstädtner
July 02, 2019Software engineer at makandra GmbH

RubyMine comes with a nice way to grep through your project's files: The finder (ctrl + shift + f). Don't be discouraged about the notice 100+ matches in n+ files if your searched keyword is too general or widely used in your project.

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

Image

RubyMine comes with a few ways to narrow down the resulting list, don't hesitate to apply those filters to speed up your search. Your keybinding might vary based on your personal settings.

File mask (alt + k)

If you already know the file extension of your desired search results, apply a file mask:

# Only SASS files
*.sass

# Exclude all SASS files
!*.sass

# Only SASS files OR CSS files
*.css,*.sass

Directory (alt + d)

Limiting your search results for example to the /app/ directory can be helpful to exclude all test files.

The probably easiest way to start this kind of search is from the project tree: mark the directory and start a search (ctrl + shift + F or right click and "Find in File..."). The directory filter will be automatically filled with the marked directory.

Regex (alt + x)

Your possibilities are almost endless here - you can use the full power of regular expressions. My most frequent use for this option is to match different notations of the same concept, like a Ruby class attribute (snake_case) that is also exposed to the JavaScript world (camelCase).

# This query matches "foobar", "foo-bar" and "foo_bar"
# The query is case insensitive be default.
foo.?bar

And more

RubyMine offers further options like toggling case sensitivity, excluding comments or including the source code of your gems.

All of those options can be combined. Just try not to manually parse 100+ matches of a too general search term.

Posted by Michael Leimstädtner to makandra dev (2019-07-02 11:33)