How to set 'File Search' as the default dialog when pressing CTRL + H in Eclipse or STS?

Learn how to set 'file search' as the default dialog when pressing ctrl + h in eclipse or sts? with practical examples, diagrams, and best practices. Covers eclipse, full-text-search, keyboard-shor...

Set 'File Search' as Default for CTRL + H in Eclipse/STS

Hero image for How to set 'File Search' as the default dialog when pressing CTRL + H in Eclipse or STS?

Learn how to configure Eclipse or Spring Tool Suite (STS) to open the 'File Search' dialog directly when pressing CTRL + H, streamlining your code navigation and search workflow.

Eclipse and Spring Tool Suite (STS) are powerful IDEs offering a wide array of features for developers. One frequently used feature is the search functionality, typically invoked by pressing CTRL + H. By default, this shortcut often opens the 'Java Search' or 'Git Search' dialog, depending on your context and installed plugins. However, many developers prefer to default to the 'File Search' dialog for quick text-based searches across their workspace. This article will guide you through the process of reconfiguring this shortcut to prioritize 'File Search', enhancing your productivity.

Understanding the Default Search Behavior

When you press CTRL + H in Eclipse or STS, the IDE attempts to open the most contextually relevant search dialog. For Java projects, this often means the 'Java Search' dialog, which is optimized for searching Java elements like types, methods, and fields. Similarly, if you have Git integration active, 'Git Search' might be the default. While these specialized searches are useful, a general 'File Search' (which searches for text strings within files) is often the most common initial search for many developers. The IDE's default behavior can lead to an extra click to switch to 'File Search' every time, which can become tedious over time.

flowchart TD
    A[Press CTRL + H] --> B{Default Search Dialog?}
    B -->|Java Project| C[Java Search]
    B -->|Git Context| D[Git Search]
    B -->|Other Context| E[Other Specialized Search]
    C --> F{Switch to File Search?}
    D --> F
    E --> F
    F -->|Yes| G[File Search]
    F -->|No| H[Continue with Default]
    G --> I[Perform Text Search]
    H --> J[Perform Specialized Search]

Default Eclipse/STS Search Workflow

The 'File Search' dialog offers a robust way to search for any text string within your project files, supporting regular expressions, case sensitivity, and scope limitations. For tasks like finding all occurrences of a specific variable name, locating a particular log message, or identifying code patterns, 'File Search' is indispensable. Making it the default saves you precious seconds on every search operation, contributing to a smoother and more efficient development experience. This small customization can significantly impact your daily workflow.

Configuring the Default Search Dialog

Eclipse and STS allow you to customize which search dialog appears first when you invoke the search shortcut. This is managed through the 'Preferences' menu, specifically under the 'General' -> 'Search' section. You can reorder the available search pages, effectively setting your preferred default.

1. Open Preferences

In Eclipse or STS, navigate to Window > Preferences (on macOS, it's Eclipse > Preferences).

2. Navigate to Search Settings

In the Preferences dialog, expand General and then select Search.

3. Reorder Search Pages

On the right-hand side, you will see a list of 'Search Page Order'. Locate 'File Search' in this list. Select it and use the Up button to move it to the top of the list. This tells Eclipse to prioritize 'File Search' when CTRL + H is pressed.

4. Apply and Close

Click Apply and Close (or Apply then OK) to save your changes. The next time you press CTRL + H, the 'File Search' dialog should open directly.

Hero image for How to set 'File Search' as the default dialog when pressing CTRL + H in Eclipse or STS?

Moving 'File Search' to the top of the Search Page Order in Eclipse Preferences.

After performing these steps, pressing CTRL + H will now immediately bring up the 'File Search' tab, saving you an extra click and making your search workflow more efficient. This small customization can significantly improve your daily development experience in Eclipse or STS.