Choose between open declaration/implementation on Ctrl + click in IntelliJ IDEA
There is not a built-in option for this. You would need to configure a custom quick list to do such.
- Open the Settings dialog and go to "Quick Lists" (It's under "Appearance & Behavior" in IDEA 14)
- Click the add button to the right of the middle pane
- Give your list a name
- Click the add button to the right of the far right pane (where is reads "no actions")
- Add the Go to Declaration action (Main Menu > Navigate > Go to Declaration)
- Add the Go to Implementation(s) action (Main Menu > Navigate > Go to Implementation(s))
- Click Apply
- Go to Keymap in the settings
- Under the "Quick List" node, find the Quick List you just created and map a short-cut (keyboard or mouse) to it. You can, of course, remap one of the shortcuts used by the Go to Declaration or the Go to Implementation(s) action
- Click OK to close out of the settings and give it a try.
Note that in the quick list that opens, you will have numbers next to each action for quick selection.
Edit: Adding a screenshot of final quick list for additional clarity
I was looking for the same thing, because I was also used to it in Eclipse. Nevertheless, in 99% of the cases, I went to the implementation. If that's your case too, you may consider changing the Ctrl+click shortcut in IntelliJ:
- Open File → Settings... → Keymap
- Search for "implementation", and identify the item "Main menu → Navigate → Implementation(s)" in the list
- Right-click the item and choose "Add Mouse Shortcut"
- Add the Ctrl+click shortcut by making a Ctrl+left click on the window
- When hitting the OK button, you have two choises :
- Remove the existing shortcut (opening the declaration)
- Leave the existing shortcut : In that case, when using then Ctrl+click, both the declaration and the implementation will be opened (at least when they are in different files)
I know this answer comes like 2 years too late, but hopefully it may help others?
EDIT : This shortcut also applies when you want to navigate to the declaration of a super class. Therefore, my "99%" first declared above drops a bit. I've added the ctrl + right-click as a shortcut to go the declaration (which conflicts with no other shortcut - but you need a mouse with at least two buttons...).