Searching

The Eclipse IDE provides dozens of different ways to locate things. Eclipse breaks these up into two major categories:

Find

Look for something in the current file.

Search

Look for something in multiple files.

The Find command (Ctrl+F or Edit → Find/Replace) is just a run-of-the-mill text locator like you would see in any editor. You can look for plain strings or full regular expressions, and you can optionally substitute the text you find with other text. The shortcut to find the next occurrence is Ctrl+K.

A handy variant on Find is incremental find, a feature borrowed from the Emacs editor. Press Ctrl+J(Edit → Incremental Find Next) and start typing the text you're looking for. The selection will move to the next occurrence as you type.

Searches are much more interesting. To start with, Eclipse supports locating strings and regular expressions in many files at once. You can search the entire workspace, just the current project, or any subset (called a working set) that you define. To do this kind of search, select Search → File….

Eclipse can also do a full language-aware search. Since Eclipse has its own built-in Java compiler, it understands the difference between, say, a method named fact and a field named fact, or even between two methods that have the same names but take different parameters, such as fact(int) and fact(double). This kind of search is available by selecting Search → Java….

These searches and more are accessible through the Search dialog (; Ctrl+H; ...

Get Eclipse IDE Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.