10

I find it difficult to navigate through code for a big project involving many classes, XML files, SQL files etc.

I know Shift-Ctrl-R to open resources, but thats where my little knowledge ends. How can I easily navigate through a hell of Java and non-Java files in Eclipse with just keyboard. Most of you gurus already will have a list of favorite code navigation shortcuts/tips, I suppose.

Please share.

Thanks!

Joachim Sauer
  • 302,674
  • 57
  • 556
  • 614
Nishan
  • 2,821
  • 4
  • 27
  • 36
  • http://www.allapplabs.com/eclipse/eclipse_shortcuts.htm – Nishant Mar 14 '11 at 12:19
  • 1
    You may want to look at [What's your favourite hotkey in Eclipse](http://stackoverflow.com/questions/98220/what-is-your-favorite-hot-key-in-eclipse) and [Is it possible to work in Eclipse with keyboard only](http://stackoverflow.com/questions/605644/is-it-possible-to-work-in-eclipse-with-keyboard-only) for inspiration. And/or make this community wiki as there's no single correct answer. – Andrzej Doyle Mar 14 '11 at 12:20
  • ALT + SHIFT + W + P can also be very useful to find already open classes (for example with CTRL + SHIFT + R) in your package explorer. – crusam Mar 14 '11 at 12:54

5 Answers5

16

Try these shortcuts:

Ctrl + Shift + R for opening any resources

Ctrl + E for switching between open windows

Ctrl + Shift + T for opening loaded classes

Ctrl + T for opening type hierarchy

Ctrl + O for viewing all the methods in a class / interface. Pressing this again shows you all the superclass methods too.

Ctrl + F11 to run a previously run class.

Alt + Shift + K and then J for running a class as Java Application.

Holding Ctrl when clicking on a method / class / interface opens it.

Also check out the Java Browsing perspective.

adarshr
  • 61,315
  • 23
  • 138
  • 167
8

F3 : Go to the declaration / definition of method / variable

Cmd + [ : Go back

Cmd + ] : Go Forward

Cmd + 1 : Quick Fix

Cmd + T : Shows Class Hierarchy

Cmd + Shift + o : Fix Missing Imports

Cmd + / : Comment / Uncomment code

Cmd + Shift + / : Comment/ Uncomment with block comment

Cmd + L : Go to Line

Cmd + Shift + F : Auto Formatting

Cmd + D : Delete Line

Ctrl + Q : Go to To Last Edited Place

Cmd + Shift + G : Search the Workspace for references to the selected method or variable

Cmd + Shift + R: Open any file quickly without browsing for it in the Package Explorer:

Cmd + Shift + T: Open a type (e.g.: a class, an interface) . Unlike the previous shortcut, this even works when you don’t have the Java source file in your workspace

Cmd+Shift + P : Find Closing Brace.

Fn + Option + Del : Delete next word

Option + Del : Delete previous word

Shift + Fn + Cmd + Del : Delete to the end of the line

Shift + Cmd + Del: Delete to the start of the line

Shift + Cmd + L : List all Eclipse Keyboard Shortcuts

Cmd + K : Find Next

Shift + Cmd + K : Find previous

Cmd + Enter : Insert line above

Shift + Cmd + Enter : Insert a line below

Alt + Shift + R : Renames variables / methods / classes, renaming the class files if necessary. Also fixes all references

vaichidrewar
  • 9,251
  • 18
  • 72
  • 86
4

Alt + Left Arraow -- Goes back (just like in a browser)

Alt + Right Arraow -- Goes forward

Ctrl + Q -- Goes to the last edited line of code

Also a usefeul tip when looking for classes is to press Ctrl + Shift + T and partially type the name of the class/interface/enum that you look for. For instance, if you were to look for a class named StringParserHelper, you could type SPH, or StrPH, or String*Hel, or *ParH. Exercise with the combinations. This will help you allot.

Ctrl + . Goes to next problem (compilation error or warning) Ctrl + , Goes to previous problem (compilation error or warning)

There are many useful shortcuts. You can look at them by pressing Ctrl + Shift + L. Press it twice and you will be edit the keyboard shortcuts.

jumping-jack
  • 237
  • 1
  • 3
2

Navigating code with Eclipse, using the keyboard? Here are some shortcuts I use with high frecuency:

  • F3: while on a class name, a method name, or a variable reference, it opens the selected element declaration.
  • F4: Opens the type hierarchy view for the selected element (a class, or method...)
  • Shift+Ctrl+T: search and open a Java Type (note that it won't search on JSPs, XML files, etc. only will search the classes declared)
  • Ctrl+F6: Opens a dropdown with the list of open files (so you can change from one to another).
  • Ctrl+F7: Dropdown with the available views. It allows you to switch from code editor to the Navigator view (so you can open other files)

There are lot more, but I use thess few continually

Tomas Narros
  • 13,390
  • 2
  • 40
  • 56
0

To add up a few

Ctrl Shift O - To organize imports

Ctrl 1 - To get suggestions on a specific line

Abdullah Khan
  • 12,010
  • 6
  • 65
  • 78