Eclipse: Shortcuts

I love my keyboard shortcuts and I actively seek out ways to use the mouse less. I find the keyboard to be more efficient than a mouse for so many tasks!

This article is about some of the very cool short-cuts that I use most, plus how you can make your own and export them for future use.

13/11/2007 12:31:46 PM Updated layout of this tutorial.

Index

  1. Open Files in the Workspace
  2. Views and Actions
  3. Navigate or Search within the Workspace
  4. Navigate between Editors, Views, Perspectives
  5. Show me the shortcuts
  6. Save your shortcuts

Open Files in the Workspace

Control + Shift + T to open up any type loaded by your projects. You can use * and code>? as wild-cards here.

The same can be done for resources with Control + Shift + R. Resources is the superset of files i.e. you can find Java files through this shortcut too - by typing *.java for example.

Some perspectives don't have have this shortcut enabled. To enable it, go to Window > Customize Perspective > Commands tab. In the "Available command groups" pane, scroll down to "Resource Navigation" and check its box.

Index


Views and Actions

Alt + Q, Q brings up the "Show View" view, that allows you select any Eclipse view - and use * or ? to wild-card for their names.

This is the Alt + Shift + Q menu. By default It contains short-cuts to various views. Use the up/down keys to go through the options or press the final key in the key combinations listed.

This is the Alt + Shift + X menu. It contains short-cuts to various actions and works in the same way as the menu above.

Index


Navigate or Search within the Workspace

Press F3 while your cursor is on a variable, type or method reference and you will open up the declaration of the variable, type or method. If you use it to click on a reference to code held in an external Jar file, you might need to attach the source (if you have it) for this to work.

Perhaps the single most useful tool for jumping around a class or just examining what is in a class is the Quick Outline view, Control + O.

Type in the beginning of a method, again using ? and * wild cards, and the list shortens. This is the fastest way to move between methods in a large class. Control + O, type enough to narrow the methods down, arrow down and press enter. Much faster than the scrolling through a class or even scrolling through the outline view itself.

There are, of course, plenty of short-cuts I use that don't involve bringing up a pop-up of some sort.

Use Alt + Left and Alt + Right to navigate backward and forward respectively through your code "navigation" history. Control + Q visits the last edit location.

Control + Alt + G will do a file search on whatever token your cursor is within. Warning: by default, this will do a search through all files in your workspace so it might take a bit of time. Alternatively, select and copy that token, press Control + H (for the search dialog), select the tab for whatever search you want, fill it out, press enter and wait for those results. Most likely it will get your results faster, but requires a few more mouse and/or keyboard actions!

Control + Alt + H is one of my favourites: it will show the call hierarchy for whatever method your cursor happens to be within. This brings up the Call Hierarchy view and shows each chain of parseable method calls that reaches the current method: this is the caller hierarchy.

Flip it around by pressing a button in the Call Hierarchy view and you show the callee hierarchy - the methods called from the current method.

Unfortunately, this view won't help you identify methods called from within JSPs. This is the same for any other view that relies on being able to parse trees of Java elements.

Press F4 within a class to show the Hierarchy view, which shows an outline for the current class plus a tree of subclasses for the class. Again, you can flip it to show the tree of supertypes by pressing a button in the view.

Index


Navigate between Editors, Views, Perspectives

Control + F6 and Control + Shift + F6 to switch between all the editors you have open in a workspace. Personally I don't like having to use two hands for this, so I set Control + Tab and Control + Shift + Tab to this - see Show me the shortcuts!.

You can use a split screen function to display multiple editors at once. Do this by opening multiple files at once and clicking and dragging the tab of an editor to the left/right/tob/bottom of the editor view. You can switch between views in a particular partition using Control + E.

Press Control + Shift + E to bring up the "Switch to Editor" view. It has some nice functionality to let you manage editors you have open. But to be honest, if you need it, you are probably working on too many files at once!

Control + F7 and Control + Shift + F7 switches between views. I like this one enough that I changed it Control + ~ and Control + Shift + ~ - see Show me the shortcuts!

Control + F8 and Control + Shift + F8 switches between perspectives.

Index


Show me the shortcuts!

Sourceforge has a set of cheat sheets that tell you the default shortcuts for your version of Eclipse.

Check out your own shortcuts! Window > Preferences > General > Keys.

Go to the Modify tab to set your own shortcuts. I use this a lot.

In particular I set up the Shift + Alt + Q, X short cut to add all of the views that I switch between regularly. For example, to set a shortcut for the console, select the view as shown to the left. Put the cursor into the Key Sequence Name field, press Shift + Alt + Q, then C. Press Add to set the shortcut. Now, Shift + Alt + Q, C will open the Console View.

Index


Save your shortcuts

If you use multiple workspaces or use Eclipse on multiple machines and make lots of customizations to your shortcuts - or perspectives - you will know how hard it is to set up a workspace over and over. Thankfully, you can export all of these preferences and import them later. Go to File > Export > Preferences. Select "Export All" and fill out the destination path in the "To preference file" field. Click "Finish" to output a .epf file. Import these with File > Import > Preferences.

Index

Comments

Anonymous said…
Thanks very much for the information. I really love the Eclipse shortcuts

Popular Posts