Ctrlflow Blog

Categories


Recent Posts


Shortcuts for Searching in Eclipse

CtrlflowCtrlflow

The Eclipse IDE makes searching for code very easy, both with built-in functionality and third-party plugins such as Ctrlflow Code Search Professional. This is even more true when using the various shortcuts, which this post will introduce you to.

When searching for code, developers typically want to either find locations where, e.g., a method is declared or used, or examples of how it is used. Eclipse’s built-in search functionality serves us well in the first case, but can be cumbersome in the second case, where Ctrlflow Code Search Professional shines.

Eclipse Shortcuts Overview

You can get a list of all currently applicable shortcuts using Ctrl+Shift+L, but the General > Keys preference page goes further: Here, you can search for, change, or create key bindings for any command.

Searching Shortcuts Key Preferences

Shortcuts for Finding Locations

Text Occurrences

You likely already know about the standard text search Ctrl+F to search through the current file, but Ctrl+K and Ctrl+Shift+K allow you to cycle through each occurrence of the currently selected text. Use Alt+Ctrl+G for a text search across the entire workspace.

Declarations

To get a filterable list of declarations in the current file, use Ctrl+O.

When you have a Java element selected, use Ctrl+G to find all declarations of the same name in your workspace. When you have selected a type, use Ctrl+T to show its subtypes. Use this shortcut a second time to see the types’ supertypes.

Ctrl+Shift+T gives you a filterable list of all types declared in your workspace. Similarly, Ctrl+Shift+R gives you a filterable list of all files in your workspace.

References

When you have a Java element selected, press Ctrl+Shift+U to search for references to it within the current file, or Ctrl+Shift+G to search for references in the entire workspace.

Shortcuts for Finding Examples

To find code examples using Eclipse, you typically have to perform a search for a declaration or reference and then open each result in an editor. This quickly becomes cumbersome.

Searching Shortcuts, Eclipse Code Search

Using Ctrlflow Code Search Professional’s Ctrl+Alt+Shift+G shortcut while a Java element is selected will perform multiple lightning-fast searches at once. Beyond finding declarations and references, these searches will show you examples of how the element is used in the workspace. Moreover, you do not need to open any of the results in your editor; the preview allows you to immediately examine each result in context.

Searching Shortcuts, Ctrlflow Code Search

You can also the Code Search view’s search bar to instantly search for references, declarations, and String literals using any text search terms.
Last but not least, you can use Ctrlflow Code Search Professional catalogs to extend the scope of your search beyond your workspace, getting instant access to code examples for popular libraries like JavaFX, Spring, Vaadin, and the Eclipse platform.

Cheat Sheet

Search Name Search Scope Search Target Windows/Linux Key Combinations Mac Key Combinations
Find and Replace Current File Text Ctrl+F Cmd+F
Find Next,
Find Previous
Current File Text Ctrl+K,
Shift+Ctrl+K
Cmd+K,
Cmd+Shift+K
Quick Outline Current File Declarations Ctrl+O Cmd+O
Show Occurrences in File Quick Menu Current File References Ctrl+Shift+U Cmd+Shift+U
Open Resource Workspace Files Ctrl+Shift+R Cmd+Shift+R
Find Text in Workspace Workspace Text Ctrl+Alt+G Cmd+Alt+G
Open Type Workspace Types Ctrl+Shift+T Cmd+Shift+T
Quick Hierarchy Workspace Files Ctrl+T Cmd+T
Open Resource Workspace Files Ctrl+Shift+R Cmd+Shift+R
References in Workspace Workspace References Ctrl+Shift+G Cmd+Shift+G
Declaration in Workspace Workspace Declarations Ctrl+G Cmd+G
Code Search
Quick Search
Workspace + catalogs Declarations, References Ctrl+Alt+Shift+G Cmd+Alt+Shift+G
Code Search
Quick Menu
Workspace + catalogs Declarations, References Ctrl+Alt+Shift+H Cmd+Alt+Shift+H
Open Search Dialog Workspace Text, Declarations, References Ctrl+H Cmd+H
Show Key Assist NA NA Ctrl+Shift+L Cmd+Shift+L

Ctrlflow Code Search Professional

Learn more about all features