Many good editors, especially graphical based ones, allow the user to search the current file for all occurrences of a text string. Some will offer to highlight the text, others will use a search output window to show the search results. Note that this is automatically performed for the currently edited file. This is required to make an unimpeded grasp of a code base, to keep up with the thought process. Opening up dialogs and clicking and clacking breaks the flow.
Eclipse can’t do this!
Yup, its been around so long, and it still can’t do this simple thing. I could be missing something, an obscure magical key binding, a buried preference, but I’ve looked.
Lets be more accurate. The Eclipse IDE has powerful search capability and it could find all text within a file and put the results into the search result window. However, invoking this for ONLY the current edit window is a user experience failure. What are the options? Using the default key bindings:
- Ctrl-H: brings up a modal dialog window that has a plethora of options, but germane to this blog rant, nothing in the file path input.
- Ctrl-F: Another window, which is the above window lite. At least it is targeted for the current file. But, it won’t show all matches; turning off incremental just turns off searching per each keystroke into the text input field.
- Alt-F: This one will find all occurrences of text in the current file. Awesome!!! But, only for the currently highlighted text string in the editor. Sheesh, first I have to find it in order to find it. Que “The Three Stooges” theme song.
Note: Alt-F is not a default Eclipse key mapping. To map it bind the “Find Text in File” command to Alt+F in ‘In Windows’ at Category ‘Search’ for User ‘CU’.
What To Do?
Enhance Eclipse so that when the user does an Alt-F keystroke, check if text is highlighted in the current edit window. If there is, do the above. It there is no highlighted text, then put up a version of the simple search dialog that Ctrl-F would have created, but this dialog would have a new “All Occurrences” select box already checked. That was easy!
I would even do it myself except, learning the Eclipse internals and all associated devadministrivia would be a career in itself. So in the meantime lets just warm up our fingers in the morning cause they’ll have to be limber; a lot of dialogs will have to open and close just to find what your after.