11

I have a code with some constants in format ClassName.CONSTANT_NAME. I want to quickly replace this by CONSTANT_NAME. But I have not found any efficient way of doing that.

Every time I want to static import something I have to remove class name manually then open static import tooltip which might contain several matches for constant name... It is inefficient.

Is there any quick way of converting an import to a static import? Ideally I would assign a shortcut for this.

Sasha Shpota
  • 9,436
  • 14
  • 75
  • 148

1 Answers1

17

Put the cursor on the constant (ClassName.CONSTANT_NAME).

Then use the shortcut for the action Show the list of available intention actions.

  • On windows or Linux: alt + enter

  • On mac os: ⌥⏎

Then select:

  • Add on demand static import for ....
Pau
  • 14,917
  • 14
  • 67
  • 94
  • 2
    Thanks, looked for this. But for me, it would be much more useful to have the possibility to define a short cut for this. Is that possible already? Can't find a way. As I remember in Eclipse you just needed to place the cursor on somewhere of "CONSTANT_NAME" and press "shift + strg + M" I think. Would love that. – BAERUS Sep 01 '17 at 09:11