Eclipse shortcut keys are really useful for Java developers. In this article we will see how to set up eclipse shortcut to open method implementation directly. Normally, to open method implementation, we used to press the ctrl button and place the cursor over the method name and click the open implementation link. This can be made simple by setting up a shortcut key.
Quite often while working in Java files we might want to navigate to variable/method declaration. In order to navigate quickly, we can place the cursor in the variable/method name and press F3 button which takes us to the variable/method declaration. I think in eclipse F3 is set as shortcut key by default for this.
But to navigate to method implementation instead of method declaration, no shortcut is setup by default. This is quite needed because most often we will be using reference of interfaces to call a method. In this case if you place the cursor in the method name and press F3, it will only take you to the method definition in the interface. But we want to go to the method implementation defined in the implementation class. Here is how to set the shortcut key.
1. Go to Window->Preferences->General->Keys.
2. Type “Open Implementation” in the search box. Select the result.
3. Place the cursor under binding and press F4 as the shortcut key(or any key you desire. Don’t select the key which is already set as key for some other functionality). Select “In Windows” under the option When:(This says where/when this shortcut should apply)
4. Click OK.
5. Now keep the cursor in method name and press F4. You will see that it takes you to method implementation.
You can do similar steps to setup shortcut for any functionality you desire e.g. Open project, close project, copy qualified name etc.
Latest posts by Uday (see all)
- How to run shell commands using SSH connection in Java - July 26, 2017
- Java program to print rectangle of stars - July 20, 2017
- Introduction to Java Enum data type with example programs - March 31, 2017