The Dopefly Tech Blog

<< The Dopefly Tech Blog Main page

Trouble finding things in Eclipse?

posted under category: CFEclipse on August 11, 2008 at 1:00 am by MrNate

I've heard it 2 times in the last week that people are having trouble using the find features in Eclipse, so I thought I might be able to help a little.

#1 - Refresh your project files automatically
#2 - The search dialog box

Eclipse search dialog
Hit the link to read it.

#1 - Refresh your project files automatically
Eclipse caches and indexes your code, and when you search, it does not always go back to disk to re-index them. If Eclipse detects that some files are out of date and have not been refreshed, it will just skip them while searching. The solution is to either set up automatic file refreshing or refresh manually. Manually refreshing your files means selecting the part you want to refresh on the Navigator view and pressing the F5 key. You select the root of what exactly you want to refresh, so to refresh a project, select the project root and hit F5. This is not the dreamweaver site refresh thing that makes your IDE crawl while it indexes. It politely runs it in the background in ways you won't even notice it. Do yourself a favor and turn it on:

Open the preferences superdialog - Window > Preferences
Navigate to General > Workspace
Check the "Refresh automatically" checkbox
Hit OK

If you open a project that was closed (right click, open / close project options), these projects are typically out of date, so whenever I open a project, I manually refresh the files first thing.

#2 - The search dialog box
Pressing CTRL + H or navigating to Search > Search brings up the extended search dialog. In Eclipse 3.4, there is a Customize button on the bottom that will allow you to toggle on and off search types that you do or don't want to use. I turn off everything but the "File Search" tab. Seriously, this is the one you need.

The File Name Patterns text field is what files you are searching in. You can put it at "*" to search everything, but I have it at "*.cfc, *.cfm, *.css, *.html, *.js, *.xml" which is all of the relevant files in my project. This field has a limited memory from search to search but sometimes erases entries, so don't trust it.

The Scope area is important.
If you select "Workspace," you will search all of your projects, which may take a while.
If you selected one or more projects, folders or files in the Navigator view, you can search "Selected resources" - this is what I do 99% of the time.
If you have an open file selected instead of items in the navigator, you can search "Enclosing Projects", meaning projects of the files that you have open.
If you have a working set, you can select it here to search, but be careful that the working set contains all the files you are interested in, sometimes they will not see new files.

You can search just for files by name if you leave the "Containing text" area empty.

If you install Aptana, you can use a multiline search. Yep, just like old HomeSite or Dreamweaver.

If that doesn't do it for you, I don't know what will. Anyone care to comment on what other problems they may be having with searching from Eclipse? I've got to say, it works so good for me that I'm shocked when I hear people are having trouble.

Too old to comment!
On Aug 13, 2008 at 1:00 AM Ed (ekmagos who loves said:
Thanks for the search tips. I didn't know about the auto refresh. I love how powerful the search is and even use regex searches from time to time. The only downside for me is that the search results are collapsed initially and I have to click the expand all button to browse the matching code snippets.

I've searched for a way to have the results expanded by default without any luck. Any tips on this one?

On Aug 13, 2008 at 1:00 AM Nathan Strutz ( said:
I don't have a way to auto-expand the search results in tree view, but did you try the flat layout? Hit the down arrow in the top-right corner of the search results and select "Show as List" - it will give you more like a homesite style results list of just the files that were found.

Assuming you've tried that, if it's seriously a pain in the neck for you, you could always consider a plug-in that will hit the button for you... overkill, maybe, but it could be neat.

On Sep 17, 2008 at 1:00 AM defdac ( said:
In IntelliJ you just right click on the package/directory to search everything beneath it.

It took me hours finding out how to do that in Eclipse: First selecting the package/directory, then select "Find", then select "Selected Resources" and then get results... whoa..

Almost as user friendly as Microsoft Word, and that is not a good thing..
Too old to comment!