Thursday, April 21, 2011

Eclipse: Find/Replace Bar

I prefer NetBeans style Incremental Search Bar interface instead of the usual Find/Replace Dialog. Eclipse only has the Find/Replace Dialog. So I implemented a similar Find/Replace Bar for Eclipse. Here are the screenshots:



Known issue: If you have customized the perspective, the Find bar view will be shown with a tab unlike the above screenshot. Try resetting the perspective and the tab may go away. I had mixed success with that though.

Find/Replace Bar Plug-in is on Eclipse Marketplace !

Currently the Find/Replace Bar supports the following features:
  • Find as you type
  • Find Next/Find Previous
    • same key bindings as Eclipse
  • Show the total number of occurrences in the document
  • Case sensitive mode
  • Whole word only mode
  • Regular Expression mode
    • Indicate illegal regular expression
  • Show Find/Replace dialog by pressing CTRL+F on Windows and Linux and COMMAND+F on Mac
  • Enable/Disable Find/Replace Bar using preferences
    • Show Preferences button on the Find/Replace Bar
  • Optionally override the standard Find/Replace Dialog of Eclipse. Control the override through preference page.
  • Press CTRL+F on Windows and Linux and COMMAND+F on Mac to show the Find/Replace Bar
    • Press ESCAPE to hide the Find/Replace bar
    • Find/Replace Bar works with text editors inside a Multi page editor e.g. plugin.xml XML editor inside the Plug-in Manifest editor.
    • Show the preceding and succeeding match count
    • Show text matching groups in regular expressions in a combobox
    I am planning to implement the following enhancements:
    • Full Replace/Find,Replace and Replace All support
    • Find in selection
    • Highlight current and other occurrences of the matched text
      • Highlight groups in regular expressions in different colors
    • Show current line number and column range of the match
    • Make it work in Console and other views where Find/Replace dialog is applicable
      You can install it from the plug-in's update site:

      http://sandipchitaleseclipseplugins.googlecode.com/svn/trunk/FindReplaceBarUpdateSite/

      Please file any issues at:

      http://code.google.com/p/sandipchitaleseclipseplugins/issues/list

      After installing the plug-in, go the Find/Replace Bar preferences page to enable the Find/Replace Bar as shown in the screenshot below:



      Works on Eclipse 3.6 and 3.5.2

      Enjoy!

      22 comments:

      Shantanu Kumar said...

      This is very neat. Thanks for putting this up.

      Tor Norbye said...

      Looks cool. By the way, I only did week discovered that Eclipse already has incremental find (Cmd-J on mac), which is better than a full dialog popup (Cmd-F), but I still miss the actual search bar showing up on top of the editor instead of just reusing the bottom status bar so your plugin looks promising!

      Sandip Chitale said...

      Thanks Tor.

      I always knew of incremental find (Cmd-J) but like you, I was not fully satisfied with the functionality it provides i.e. cannot edit the find text in the status bar, no history etc.

      Peter said...

      I'm eager to use it, but it doesn't work on 3.6.2 and 3.7M6. The plugin installs and I can set the preference, but CTRL-F still results in the standard Find Dialog.

      Peter said...

      I'm eager to use it, but it doesn't work on 3.6.2 and 3.7M6. The plugin installs and I can set the preference, but CTRL-F still results in the standard Find Dialog.

      Sandip Chitale said...
      This comment has been removed by the author.
      Sandip Chitale said...

      Hmmm...it works for me on Eclipse Classic 3.6.2. Did you have any problem during installation? Is there any message in the Error Log view?

      Couple of suggestions.

      - Try it in a different perspective.
      - Explicitly show the Find/Replace Bar view by using Window > Show view > Other
      - If you do not mind try resetting the perspective

      Just tried on Eclipse 3.7M6 and it worked for me.

      Javin Paul said...

      Nice tip , thanks for sharing this. will it work in Eclipse Europa as well ?

      Javin
      java remote debugging in Eclipse

      Anonymous said...

      Cool. I much prefer this to the freefloating dialog. It's silly in Eclipse that there is a powerful search replace for multiple files that cannot easily be leveraged for the current editor. I miss JEdit's approach.

      Sandeep said...

      Great addition

      Extreme Java

      Peter said...

      Resetting the perspective did the trick. Thx.

      BTW: the plugin.xml has:

      relative="org.eclipse.ui.editorss"

      "ss" at the end. typo?

      Sandip Chitale said...

      @Javin Paul, I have not tried it with Europa. Probably will not work.


      @Peter, "org.eclipse.ui.editorss" is not a typo. It is constant defined in Eclipse code like this:


      public static final String org.eclipse.ui.IPageLayout.ID_EDITOR_AREA = "org.eclipse.ui.editorss"; //$NON-NLS-1$

      Anonymous said...

      Useful plugin.

      I have set it to override Ctrl+F to open Find/replace bar. In eclipse 3.6 it opens a new view with a tab and in eclipse 3.7 it opens a bar without a tab. Is that expected?

      Sandip Chitale said...

      @Anonymous

      Find/Replace bar IS implemented as a standalone, non-closable, non-movable view with no title to give the appearance of a bar below the editor. I have done it using the org.eclipse.ui.perspectiveExtensions. I think there is a bug or shortcoming in Eclipse implementation whereby the tab is shown if the user has customized the perspective. If you do not mind try resetting the perspective and that may make the view's tab to disappear.

      Abhi said...

      Are you planning to have a shortcut key for toggling between whole word find and non whole word find?

      Sandip Chitale said...

      No. But I will add it as an enhancement here:

      http://code.google.com/p/sandipchitaleseclipseplugins/issues/list

      Sandip Chitale said...

      @Abhi

      Added the keyboard shortcuts you requested. Get version 1.0.15 or later.

      jmdesp said...

      Hi, I'm wondering if you'd be willing to open source your old Netbeans NBJAD plugin so that it can be updated to newer version of Netbeans ?

      Apparently nobody wrote an alternative decompilation plugin that could be used with never versions.

      Sandip Chitale said...

      @jmdesp the NBJAD plugin is already open source. You can access it here.

      jmdesp said...

      Great ! And it's up to date. But there's no ready package generated ?

      It would be useful for the plugin page http://services.netbeans.org/pluginportal-2.0/plugin/1177/nbjad to receive some update telling about the hg contrib site

      fireman_bob said...

      Hi, I installed this for CCS5 and it appears in a box below the editor window. Is there a way to get the find bar fixed in the top row of icons?

      fireman_bob said...

      Hi, I installed this for CCS5. Is there a way to get the find bar fixed with the row of icons across the top?