DEV Community

loading...

What are your favorite IntelliJ shortcuts?

chrisvasqm profile image Christian Vasquez ・1 min read

I'm a shortcut junkie, I love learning new ways to take control over the tools I use, whether it is IntelliJ, VS Code, or even a browser!

That's probably because I watched way too many episodes of Mr Robot.

I'm not gonna lie, it does make me feel a little bit like:

Hackerman

Discussion (14)

pic
Editor guide
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
chrisvasqm profile image
Christian Vasquez Author

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).
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
shriharshmishra profile image
Shriharsh • Edited

I like to de-clutter the screen using Ctrl + Alt + F12 and using Alt + 12 to open up the terminal. I use Alt + n command to open up the panels with numbers. For e.g. Alt + 1 to open the project panel.

I use it with Vim plugin so I am mapped Alt + I to navigate to the source.

Collapse
evanoman profile image
Evan Oman

Here are my most used shortcuts:

  • CTRL-Q: Brings up docs
  • CTRL-B: Go to definition
  • SHIFT-F6: Rename
  • CTRL-SHIFT-T: Generate Empty Test Class <-- LOVE this
  • CTRL-ALT-O: Optimize imports (do this habitually all the time)
Collapse
chrisvasqm profile image
Christian Vasquez Author

Woof!

Really nice ones!

I ended up overriding the default Rename shorcut since I like having the F# keys for controlling brightness and all that jazz without having to press the Fn key.

And CTRL-ALT-O + CTRL-ALT-L is as natural as breathing for me! hahaha.

Collapse
craser profile image
Chris Raser

YES! Generate Test FTW.

Collapse
chrisvasqm profile image
Christian Vasquez Author • Edited

For me it's gotta be the Find Action shortcut that gets triggered by pressing CTRL + SHIFT + A on Windows or CMD + SHIFT + A on macOS.

Since I constantly have to switch from my personal machine running macOS to Windows when I'm in the office, this is my safety net whenever I can't remember an specific shortcut. You can just type in the words and let the magical search do the rest.

Collapse
craser profile image
Chris Raser

I like Fabian's list, and I have one more: I have Show Intention Actions mapped to Alt-Return, and I use that all day long. I use that to declare local variables, create missing methods, create classes, etc.

Collapse
jeremiebeaudoindion profile image
Jérémie Beaudoin-Dion

I don't know about you, but there are a few that I love and one I REALLY don't like!

It's ALT+PERIOD

I use the French keyboard and to put a ">" I need to press just that. So every time I switch computer I need to change the shortcut for custom foldings.

I didn't know about Shift+F6! Really useful!

Collapse
danedens profile image
Dan Edens • Edited

Have you heard of Eventghost?
Lets you take control of windows and automate all kinds of stuff, I have short cuts for the wildest stuff dude.

dev-to-uploads.s3.amazonaws.com/i/...

Collapse
cahyowhy profile image
cahyo wibowo

Ctrl alt l = format code
Tab arrow = move tab
alt insert = create constructor, getter & setter
alt mouse click left (windows) = insert caret
ctrl shift n = search file

Collapse
chrisvasqm profile image
Christian Vasquez Author

Oh, I normally use Search Everywhere by double tapping SHIFT instead of the Search File, it's probably a faster way of finding an specific file.

And ALT + Insert is really good! Combining it with ALT + 1 to open and focus on the Project Explorer it let's you create new files too (depending on the folder you are highlighting).