Saturday, April 12, 2008

Eclipse Shortcuts: or To Eclipse and Back Again

Recently I shifted from coding in VisualStudio+ReSharper to coding in Eclipse. Again. And me being very much a keyboard shortcuts person, I needed to find Eclipse equivalents for all my favourite ReSharper shortcuts. Déjà bloody vu. So I decided I'll spend some time and record the Eclipse versions of my oft used shortcuts for the next time. Here they are:

Most Used
Ctl+Space : completion
Ctl+1 : Quick fix suggestions
F2 : Show tooltip (javadoc, help)
Navigate
F3  : Go to declaration
Ctl+Sh+T : Open type (class)
Ctl+Sh+R : Open resource (file)
Ctl+O : list class members
Ctl+. : Next error/warning/search result
Ctl+E : switch to an open file
Alt+Left : Previous cursor location
Alt+Right : Next cursor location
Ctl+Q : Last edit location
F12 : activate editor
Ctl+M : maximise or restore active view
Ctl+J : Incremental search
Ctl+Sh+J : Incremental search backwards
Ctl+Sh+G : Find references in workspace
Ctl+Alt+H : Open call hierarchy
Alt+Sh+Q,S : open search view
Ctl+F7 : cycle through views
Alt+Sh+Q,P : package explorer
Debug
Alt+Sh+D : Debug menu
Ctl+Sh+B : toggle breakpoint
Ctl+Sh+I : inspect
F5 : Step into
F6 : Step over
F7 : Step out
F8 : Resume
Launch
Alt+Sh+X, T : Run tests
Ctl+F11 : Run last launched
Refactor

Alt+Sh+T : Refactoring Menu
Alt+Sh+M : Extract Method
Alt+Sh+R : Rename
Alt+Sh+C : Change method signature
Alt+Sh+I : Inline variable/method
Alt+Sh+L : Extract local variable
Alt+Sh+V : Move
Code
Ctl+Sh+F : Format
Ctl+Sh+O : get rid of redundant import statements
Alt+Sh+Up : select enclosing element/widen selection
Alt+Sh+Down : narrow selection
Alt+Sh+S : Source menu (override, create constructor,...)
Alt+Sh+Z : Surround with menu (try/catch, for,...)
Alt+/ : word completion
Ctl+Alt+Up : duplicate line

One of these days I should make this list for ReSharper and IDEA as well.

In the meanwhile, if there are any of your favourites I've missed, do let me know.

4 comments:

Anonymous said...

You missed the most important one: CTRL+Shift+L = list shortcuts

:)

Anonymous said...

Nice list. I am currently going the opposite direction, from Eclipse to VS/ReSharper, and having a heck of a time. I, like you, have a mouse aversion.

One of my favorite shortcuts you left out for Eclipse is Ctrl+T, which will open up a window similar to Ctrl+O, only for implementations of an interface.

For example, given the following interface/classes:

public interface Foo {
   void baz();
}

public class FooOne implements Foo {...}
public class FooTwo implements Foo {...}

Now, if you're in some code that has a Foo reference you can use the Ctrl+T goodness on it.

public void doSomething(Foo f) {
   f.baz();
}

Pressing Ctrl+T on the baz method returns a view something like this:

(I) Foo
     |
      ----> (C) FooOne
     |
      ----> (C) FooTwo

Selecting the appropriate class from the dropdown will take you to the baz method in the selected class.

Looking forward for your VS/ReSharper list!

Brandon

Rohith Rajagopal said...

Jonnyleroy - thank you for reminding me of Cl+Sh+L. I used it once to get the list of shortcuts, and pick the ones I wanted, but then I clean forgot about it.

Brandon - I considered Ctl+T but didn't quite understand what it was doing - probably because I tried it on a method without an implementation! From what you are saying, it looks like ReSharper's Ctl+Alt+B: show implementing members. If so, I can definitely see it becoming one of my favourites.

Anonymous said...

I have made a plugin for Eclipse implementing the exact behaviour of Ctrl+Alt+B in ReSharper. You can find it here: http://eclipse-tools.sourceforge.net/implementors/