views:

4285

answers:

25

I've been using Visual Studio with Re-Sharper for the past few years and have recently taken a gig at a Java shop where we use Eclipse. Googling for Eclipse hotkeys has returned a bunch of 'Top 10 Hot-Key' posts, but that's about it.

What are your favorite hotkeys? And which are essential?

+2  A: 

CTRL-SHIFT-R to jump to a file - it is a must on large projects

RichH
+4  A: 

Holding CTRL so you can click on class names and jump to that class is probably the shortcut I use the most

(except save, copy ... as David says)

RichH
+1  A: 

CTRL-ALT-UP/DOWN ARROW to copy the line or selection is pretty cool. And one I miss in Netbeans, so if anyone knows the equivalent...

David Turner
+11  A: 

These are the ones I file under "muscle memory."

Editing

  • Ctrl+Shift+O - organise imports (removes unused imports, adds missing imports, sorts imports)
  • Ctrl+Shift+I - unindent selection
  • Ctrl+/ - comment/uncomment selected lines
  • Alt+Shift+R - rename selection

Navigation

  • Ctrl+Shift+T - find as you type for Java classes in your projects
  • Ctrl+Shift+R - find as you type for all resources in your projects
  • Alt+Left - step backwards through editing history
  • Alt+Right - step forwards through editing history

Execution

  • Ctrl+F11 - run again
  • F11 - run again in debug mode
insin
+1  A: 

CTRL-SHIFT-T Type in classname. Comes with search, .. and * being wildcards. You can lookup Java inbuilt classes ( if you tell Eclipse about you jdk instead of your jre. ).

Extremely useful for Java development, if only to find that special purpose class eluding your mind.

Sid Datta
+9  A: 

ctrl + space: auto complete. Completes everything, including the kitchen sink.

The best there ever was!

jjnguy
+4  A: 
  • Ctrl-space Auto complete
  • F3 Open definition: jumps to the definition of the class, method, variable, even if it is in remote places (such as classes in the JDK itself)
  • Ctrl-Shift-T Find Type: also finds Java classes that do not have their own files (such as classes in jar files). Note that you can use CamelCase: type NPE instead of NullPointerException.
  • Ctrl-Shift-R Find Resource: opens any kind of file. Much faster than trying to navigate to them
  • Ctrl-Z Undo: Eclipse can undo a lot (such as undelete files) and has a very long undo buffer for its text editors
Thilo
+5  A: 

Ctrl-Shift-F to format code! :)

Along with Ctrl-Shift-O, I always do this before saving or committing. Together, these two shortcuts help keep everything clean and consistent.

BTW, there's more good stuff here: http://stackoverflow.com/questions/20529/useful-eclipse-features

David Crow
Eclipse 3.5 added the ability to run all of this when you save. You should look into that so you don't even have to do it manually anymore.
John Munsch
+7  A: 

Ctrl + 3 - Quick Access

Quick access provides access to almost any view, perspective, menu item, simply by typing it. It's great for allowing you to keep your hands on the keyboard and away from the mouse.

Jon Ball
+5  A: 

Ctrl + 1 - suggestions and quick fixes. Try it in the following way, write a call to any method press the combination and voila! you eclipse declares a variable for you of the proper type. Another is to mark a block press Ctrl+1 and extract local variable appears as first option.

Ctrl + q - go to last edited place.

Bauna
+1  A: 

Ctrl + Shift + M - Add Import. Love to see those red underlines disappear.

Evgeny
+1  A: 

Ctrl+F6 : switch editors

Ctrl+F7: switch Views

Ctrl+F8: switch perspectives

Soumitra
+2  A: 

Ctrl+Shift+F (Format code) is pretty much the one I use the most.

It's also one of the reasons I much prefer working with Java in Eclipse than with C# in Visual Studio (though I use both extensively) - the code formatter in C# is pretty weak.

Roy Tang
Make it a save action and things magically happen when you press Ctrl-S
Thorbjørn Ravn Andersen
+2  A: 

Everyone from @insin, and more:

Control-1: It suggests solutions.
Alt-Shift-M: Creates a new method.
Alt-Shit-I: Inline variables/methods.
Control-2, L: Creates the variable declaration.
Control-2, F: Creates the field declaration.
Control-O (not zero, but the vocal): Shows the outline of the document.
F4: Shows the hierarchy.
Alt-Shift-Q, Q, P, T...: Shows a view.
Alt-Shift-W: Shows in.
Alt-Shift-ArrowUp: Previous method.
Alt-Shift-ArrowDown: Next method.
Control-Shift-E: Shows a dialog with a line for each open editor.
Control-E: Shows an editor selection mini window.

I use all of them every day!

I don't use Control-Shift-O and Control-Shift-I because I have activated the "Save actions" and they are executed automagically when I save documents.

Sorry, these ones are more than 10.
Sure, in a few minutes I will remember other shortcuts, :-)

Banengusk
+1  A: 

Ctrl-Shift-T rules. Especially after you discover that you only need to type in the capital letters of the class name. So to quickly look up class MyLongClassName, I only need to type Ctrl-Shift-T,M,L,C,N

Diastrophism
+1  A: 

F3 is only mentionend once, but F3 is along with CTRL+Shift+T the most useful shortkey.

boutta
+1  A: 

Alt + Shift + Z = "Surround With"

Select a block of code and hit this hot key to pop up a little menu to create a try-catch block, conditional or loop.

anon
+1  A: 

Ctrl + 7 - Comment / uncomment the selected code.

CTRL + D - Deletes the selected line(s).

syso + CTRL + SPACE - creates: System.out.println();

eflles
+1  A: 

Allt+Arrow Up or Down - Move current line/selection up or down

John Nilsson
+2  A: 

A note about ctrl-O: Typing once will only give you the current class's outline. Hitting it a second type will give you all the inherited stuff - Often much more useful.

Same thing about ctrl-T: Once will give you supertypes, twice should give you interfaces as well.

Uri
A: 

Ctrl-Shift-I (or whatever it is on the PC): Automatic indentation.

Uri
+2  A: 

Alt+F4

:) It means it's the end of the day.... ( don't downvote its friday night already ) :S

OscarRyz
+1  A: 

alt+shift+S, then r is for generate getters and setters. It looks tricky but once you get used to this combination you cannot live without it.

diega
A: 

Alt-F4 to close the useless thing down and fire up emacs. :)

anio
+1  A: 

Besides the great ones already mentioned:

CTRL+SHIFT+L - Gives a quick reference of Eclipse Hotkeys (at least in Galileo JEE)

CTRL+M - Maximize Page

CTRL+2 - Various quick assist tips - (be patient with this hotkey combo as there is a sleight delay before the assist)

CTRL+F3 - (once - Show class methods and variables)

CTRL+F3 - (Hit this hot key combo twice to see inherited members and methods)

Terry Trippany