I want to show you a mix of five different keyboard shortcuts when using Eclipse for Java Developers. In case you are not already using these shortcuts try to incorporate them in your work and test which of them help you the most. If you just use a few of them more frequently in the future I am pretty sure that they will speed up your overall workflow. So let’s get started.
Refactor Move: Alt+Cmd + V
Let’s say you have a few classes that you want to move to another directory. You could use the mouse for that and select and drag and drop the files into place but here’s an alternative. Simply select the files you want to move, hit Alt+Cmd V, select the destination package, confirm and you are done.
Refactor Rename: Alt+Cmd + R
If you want to rename a class you can select the class and press F2 to rename the file and the class in it. If you want to rename a method instead, place the text cursor on the method name and press Alt+Cmd + R, change the name and confirm your change by pressing Return. This way all the occurrences of the old method name in your code will be automatically updated.
Source code context menu: Alt+Cmd + S
Let’s say you want to generate getter and setter methods for a Java bean class. Just navigate the text cursor to the start position, press Alt+Cmd + S, move the selection to “Generate getters and setters” using the arrow keys, confirm with Enter, select the desired fields and confirm the dialog with Enter again.
Assign to local variable: Cmd+2 L
Assume you just wrote a little stream that maps certain data into another format. You want to continue using the result and want to store it in a local variable. Press Cmd+2 and then L to generate the necessary code.
Javadoc comment: Alt+Cmd J
Adding comments to non trivial code may be crucial to understand it later when you need to make changes. Depending on where you place the text cursor you can add Javadoc comments your code by pressing Alt+Cmd and J.