In Eclipse, search for all text in current file?

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.

Current Options
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:

  1. 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.
  2. 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.
  3. 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.

Related

Similar Posts:

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.

3 thoughts on “In Eclipse, search for all text in current file?”

  1. In active editor simply use the incremental search / find as you type with +, which will mark the first occurence, afterwards navigate with Arrow up + down. It’s my most used shortcut beside + which means jump to last edit – useful after talking to the boss or some interrupting phone call. Use
    ++ to see all shortcuts available in Eclipse.
    //Gilbert

    1. oh, seems like html tag syntax is annihilated, so here again without html tag syntax :
      In active editor simply use the incremental search / find as you type with Ctrl + j , which will mark the first occurence, afterwards navigate with Arrow up + down. It’s my most used shortcut beside Ctrl + q which means jump to last edit – useful after talking to the boss or some interrupting phone call. Use
      Ctrl + Shift + L (downcase) to see all shortcuts available in Eclipse.
      //Gilbert

  2. Gilbert,
    Thanks for the input. Yes that is a work around that I have used.

    However, what I was after was specifically finding all occurrences into and putting these into the output Search view. This is possible in most text editors, for example, NotePad++.

    — Josef

Leave a Reply

Your email address will not be published. Required fields are marked *