Sunday, October 10, 2010

Top 30 Eclipse Keyboard Shortcuts for Java Programmer



This tutorial is about 30 Eclipse keyboard shortcuts, this list is by no means complete and I will suggest you guys to share eclipse shortcuts listed other than here to make this more useful.Eclipse is most used Java development IDE and knowing Eclipse shortcuts not only improve your productivity but also makes you more efficient, you will have more time for things you like to do. Using keyboard shortcuts also helps to impress colleagues and shows that you have good hold on tools you used for Java Development.


I was big fan of Netbeans IDE before coming across Eclipse because I was from J2ME background and Netbeans provide sophisticated IDE environment to enable you to build, debug and run your Java application in various emulator including some advanced processing options e.g. preprocessing, setting up Exception break-point etc. From that time I love to know keyboard shortcuts on IDE and other tools I used for development including Edit Plus, Microsoft Excel etc.

But when I join an investment bank I came across Eclipse IDE, since everybody in my team is using and Netbeans IDE was not available in company (don’t know why that was not allowed net-beans even though it was free) I have decided to go Eclipse way, later I found that Eclipse was most suited for those application given some of cool feature of eclipse e.g. Remote Debugging, Conditional Breakpoints, Exception breakpoints and Ctrl+T and Ctrl+R kind of shortcuts.

Here I am sharing list of 30 Eclipse keyboard shortcuts which I found most useful and using in my day to day life while writing code, reading code or debugging Java application in Eclipse.

Eclipse Keyboard Shortcuts


1)      Ctrl + T for finding class even from jar

This keyboard shortcut in Eclipse is my most used and favorite shortcut. While working with high speed trading system which has complex code I often need to find classes with just blink of eye and this eclipse keyboard shortcut is just made for that. No matter whether you have class in your application or inside any JAR, this shortcut will find it.

2)      Ctrl + R for finding any resource (file) including config xml files

This is similar to above Eclipse shortcut with only difference that it can find out not only Java files but any files including xml, configs and many others, but this eclipse shortcut only finds files from your workspace and doesn’t dig at jar level.

3)      Ctrl + 1 for quick fix

This is another beautiful Eclipse shortcut which can fix up any error for you in Eclipse. Whether it’s missing declaration, missing semi colon or any import related error this eclipse shortcut will help you to quickly short that out.

4)      Ctrl + Shift + o for organize imports

Another Eclipse keyboard shortcut for fixing missing imports. Particularly helpful if you copy some code from other file and what to import all dependencies.

Eclipse Shortcut for Quick Navigation

In this section we will see some eclipse keyboard shortcut which helps to quickly navigate within file and between file while reading and writing code in Eclipse.

7) Ctrl + o for quick outline going quickly to method
9) Alt + right and Alt + left for going back and forth while editing.
12) Alt + Shift + W for show in package explorer
13) Ctrl + Shift + Up and down for navigating from member to member (variables and methods)
15) Ctrl + k and Ctrl + Shift +K for find next/previous
24) Go to a type declaration: F3, This Eclipse shortcut is very useful to see function definition very quickly.

Eclipse Shortcut for Editing Code

These Eclipse shortcuts are very helpful for editing code in Eclipse.
5) Ctrl + / for commenting, un commenting lines and blocks
6) Ctrl + Shift + / for commenting, un commenting lines with block comment
8) Selecting class and pressing F4 to see its Type hierarchy
10) Ctrl + F4 or Ctrl + w for closing current file
11) Ctrl+Shirt+W for closing all files.
14) Ctrl + l go to line
16) Select text and press Ctrl + Shift + F for formatting.
17) Ctrl + F for find, find/replace
18) Ctrl + D to delete a line
19) Ctrl + Q for going to last edited place


Miscellaneous Eclipse Shortcuts

These are different Eclipse keyboard shortcuts which doesn’t fit on any category but quite helpful and make life very easy while working in Eclipse.

20) Ctrl + T for toggling between super type and subtype
21) Go to other open editors: Ctrl + E.
22) Move to one problem (i.e.: error, warning) to the next (or previous) in a file: Ctrl +. For next, and Ctrl +, for previous problem
23) Hop back and forth through the files you have visited: Alt + and Alt + , respectively.
25) CTRL+Shift+G, which searches the workspace for references to the selected method or variable
26) Ctrl+Shift+L to view listing for all Eclipse keyboard shortcuts.
27) Alt + Shift + j to add javadoc at any place in java source file.
28) CTRL+SHIFT+P to find closing brace. Place the cursor at opening brace and use this.
29) Alt+Shift+X, Q to run Ant build file using keyboard shortcuts in Eclipse.
30) Ctrl + Shift +F for Autoformating.

Please post if you guys have some more useful Eclipse keyboard shortcuts as comments, I will include them in this list. These Eclipse shortcuts will mostly work almost all Eclipse versions e.g. 3.5, 3.6 Helios, Eclipse Ganymede and Indigo. Let me know if you face any issue while using these Eclipse shortcuts in any particular version of Eclipse IDE.

19 comments :

Gautam said...

Good list of short cuts. Should have mentioned Ctrl-Shift-L to get this list and Ctrl-Shift-L twice to customize it.

Anonymous said...

1) Ctrl + T for finding class even from jar

Ctrl + T is the shortcut for Quick Hierarchy (Show the quick hierarchy of the selected element)

Anonymous said...

1) Ctrl + Shift + T for finding class even from jar
2) Ctrl + Shift + R for finding any resource (file) including config xml files

Javin Paul said...

Thanks for your comment Anonymous. yes Ctrl + Shift + T can be used to find classes from jar and that's what the difference between Ctrl + Shift + T and Ctrl + Shift + R. I also used Ctrl + Shift + T to findout which class comes first in classpath and its very useful if you have two classes with same name in two jar's and both jar in your classpath and one of them work and other doesn't.

Javin Paul said...

Thanks for your comment Keyboard shortcuts I visited your site and it has really good collection of keyboard shortcuts for various technology including eclipse 3.0.

Javin Paul said...

Thanks Gautam for informing us about Ctrl-Shift-L. I have included in main list for benefit of we all.

Javin Paul said...

Thanks Anonymous, Its good to know that these eclipse keyboard shortcuts are useful for you.

Anonymous said...

To go along with #28 Ctrl+Shift+P, I find Alt+Shift+UpArrow or Alt+Shift+DownArrow useful when both braces are not visible on the same screen.

Place the cursor next to the brace you want to match, then Alt+Shift+UpArrow and the matching braces and the code in between will be highlighted. Pressing Alt+Shift+UpArrow again expands the selection further. The highlighting can make brace matching much more evident.

Furthermore, this highlighting can be used on any logical block of code - put the cursor in the middle of any word (a string, a method,...) and try it.

Anonymous said...

Ctrl+j = incremental search is superior to Ctrl+f and essential for code navigation, means just Ctrl+j and type on. It will jump to the first match. Use Ctrl+j or Arrow down for the next match and Ctrl+Shift+j or Arrow up to move backwards

//Gilbert

Javin @ java.lang.unsupportedclassversionerror said...

@Anonymous thanks for your valuable suggestion, this eclipse shortcut indeed sounds quite useful , going to try it.

Anonymous said...

ctrl+shift+l displays list of all keyboard shortcuts

Abhijeet S. Sutar said...

A Master Shortcut - CTRL+3

Sandeep Kumar said...

Thanks Javin for this nice post. I've also compiled a list of useful Eclipse Keyboard Shortcuts and also uploaded a video showing how to use these shortcuts while programming.

Eclipse IDE Keyboard Shortcuts for Developers

Soya said...

My Favroties :

Eclipse shortcuts to comment and uncomment
Eclipse shortcut to formatting
Eclipse shortcut to finding Type information
Eclipse shortcut to remove all unused imports
Eclipse shortcut to run Java program
Eclipse shortcut to debug Java program

Thanks
Soya

Anonymous said...

What is Eclipse shortcut for static import in Java 5 ? is there any keyword shortcut to go from top of the page to bottom of page in Java Editor window ?

Ravindra said...

is there any book to learn Eclipse IDE? I want to master this IDE and increase my productivity by learning lots of tips, tricks and shortcuts. please let me know, if there is any comprehensive tutorial or book exists for Eclipse.

Anonymous said...

One of the keyboard shortcut I often use is Alt +Shift +s and Generate getter and Setters to generate automatic code mainly getter and setter.

AndreAgosto said...

For editor i find very useful CTRL + ALT + up(or down) to duplicate a line (or all lines selected)
also CTRL + D to delete a line (or all lines selected) is very useful

Anonymous said...

Ctrl + Home go to top of the document
Ctrl + End go to bottom of the document

Post a Comment