kgf3JfUtW
kgf3JfUtW

Reputation: 14918

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?

Upvotes: 8

Views: 2929

Answers (2)

bezbos.
bezbos.

Reputation: 2344

There is the View > Quick Definitions shortcut Ctrl + Shift + I. It works on IntelliJ 2023.x, though I'm not sure for older versions, but it probably does.

Upvotes: 1

glytching
glytching

Reputation: 47895

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

Upvotes: 13

Related Questions