DEV Community

Discussion on: What are your favorite IntelliJ shortcuts?

Collapse
 
fnh profile image
Fabian Holzer

Ctrl+Alt+M - Extract method
Ctrl+Alt+V - Extract variable/constant
Shift+F6 - Rename
Alt+F8 - Evaluate Expression (in debugging)
Crtl+Alt+O - Optimize imports

Collapse
 
mbtts profile image
mbtts

You can optionally optimise imports when formatting (Ctrl+Alt+L or ⌥⌘L).

If you add the shift key (⌥⇧⌘L) then the options will be displayed.

The options persist for subsequent formats.

Collapse
 
chrisvasqm profile image
Christian Vasquez

Oh! I've never used the Alt + F8, might have to give it a try.

About the CTRL + ALT + O to optimize imports, I've been using the automatic function inside IntelliJ's settings and it actually does a pretty good job. It's not perfect, but I would say it gets the imports right and cleans them up like 8/10 times.

This option can be enabled in Settings > Editor > General > Auto import > ... there will be 2 checkboxes for both:

  • Add unambiguous imports on the fly.
  • Optimize imports on the fly (for current project).