Search code examples
intellij-idea

IntelliJ: Is there a shortcut for "peeking declaration"?


public static final String XYZ = "something"; // line 1
return XYZ;                                   // line 2

With cursor on XYZ on line 2, I know Ctrl+B will bring me to line 1, where XYZ is defined.

Is there a way to temporarily peek at its declaration? That is, with some particular keys hold down, it goes to line 1, but returns to line 2 when I release?


Solution

  • View > Quick Definition when the cursor is on XYZ will cause a popup to display with the definition of that constant. Then you can hit ESC to dismiss the popup at which point the cursor will still be on XYZ.

    For example:

    enter image description here

    You can see the keyboard short cut for View > Quick Definition next to that menu item ...

    enter image description here