Timesavers: Ctrl-Shift-R

Monday, April 20, 2009

This is part of an ongoing series on Timesavers . The goal is simple: short, easily-digestible posts designed to help developers get faster and more productive

What you think of as files, Eclipse thinks of as resources . Resources represent a file in the Navigator or Package Explorer view; they represent a file opened in an editor. Your workspace comprises all the resources in your workspace (and a whole lot more).

This TimeSaver is dedicated to finding resources in your workspace .

How To Quickly Find Resources

By now, you should know I'm a fan of the keyboard. Navigating through trees of files is dog slow. I don't mean 8-week-old-yappy-rat-terrier-puppy slow. I mean 25-year-old-coon-hound-eyes-are-crusted-over slow. Fortunately, Eclipse gives us the "Resource" finder. Lucky people learn about this beauty early on in their Eclipse usage; others go without for a long time, to their woe. They Twitter, "How did I not know about Ctrl-Shift-R?" or "w00t! Ctrl-Shift-R!" or "OH: the dumbass in the cube beside me just found Ctrl-Shift-R. Dumbass. Wonder when he'll learn to breath out his nose".

Why is this? I think it's because of the "resource" vs. "file" nomenclature discussed above. Why, for example, would you think to: Navigator --> Open Resource and expect that to pop up the single greatest popup in the history of bits and bytes? You wouldn't. That's why it goes undiscovered for so long.

Notice the keyboard shortcut for "Open Resource": Ctrl-Shift-R . Burn that into your brain. Ctrl-Shift-R. Ctrl-Shift-R. Ctrl-Shift-R. Stop drinking. Stop eating. Stop smoking stogies. Stop raising your children. Stop everything until you have absorbed Ctrl-Shift-R. It is the fastest way to get to files. It looks like this, and it is my friend:

Notice how it filters when you type stuff? Notice I used a * to do a wildcard filter? Also, notice that little black triangle on the right hand side? You can drop that down and filter your search on Working sets for added radness.

Another neat feature: it lets you select multiple files and open them. Need to super fast find all your TestCases and open them (why? I dunno)? Ctrl-Shift-R, then *Test.cfc. Tab into the "Matching Items Window, hit Ctrl-A, then Enter. Bam... you've got more open files than you know what to do with.

Next time you find yourself grabbing the mouse and navigating through your tree of files, Stop. Put the mouse down. Even if you've found it already. Put the mouse down, hit Ctrl-Shift-R, and start typing.


Jake Munson said...

This is great, except for those times when you don't know the name of the file you need to open (which happens to me all the time, considering the amount of sites and projects I work on regularly).

Marc Esher said...

agreed. that's why for me, one huge timesaver in this respect is Mylyn. I'll be posting a lot more on Mylyn down the road. It's probably the Eclipse technology that has changed the way I work more than any other I've come across in the past few years.

Jamie Krug said...

@Marc: I must admit that went without this for a long time and recently came to love Ctrl-Shift-R! I know I looked at it a while back and something bothered me or didn't work right, but I can't imagine why now.

Also, a slightly related trick that I often use is the "Link with Editor" tool (icon with yellow arrows below the Navigator tab). When it is toggled on, whichever file is active/selected in your editor is highlighted/selected in the Navigator as well. So, if you use Ctrl-Shift-R to open a file or two and then want to browse its directory or right-click in Navigator to get to a variety of context menu options for that file, you can just toggle on "Link with Editor." I tend to leave it off, in general, so the Navigator view isn't jumping around when I switch files, but it's very useful to toggle on/off and get to a Navigator location.

Marc Esher said...

Jamie, Good point re: the "Link With" button. I tend to leave mine on, though it seems that lately I find myself untoggling it more often. Maybe it's time to unshackle myself from that little bugger.