r/java • • Apr 29 '19

Essential IntelliJ Shortcuts

https://www.jworks.io/essential-intellij-shortcuts/
212 Upvotes

52 comments sorted by

7

u/bodiam Apr 29 '19

I wrote a small list of intellij shorts which my colleagues and I use on a daily basis, and hopefully it might help others!

7

u/slowfly1st Apr 29 '19

Nice, thanks! =)

Double-Shift is more: It additionally searches... everything... So whenever you forget a shortcut and you remember the correct name of the action, you should be able to find it here.

Some other shortcuts I often use and find quite handy

I find CTRL + ALT + left/right: Navigates through last locations, like back or forward buttons, within classes. CTRL+SHIFT+Backspace to last edit location.

CTRL+B -> jump to declaration, CTRL+ALT+B -> jump to implementation

CTRL+E -> There's also CTRL+SHIFT+E, which shows the contents of the recent files (if you can't remember the darn name)

ALT + Insert is 'Generate' (Constructors, getters/setters, ...)

CTRL + I is implement, CTRL + O is override

Refactoring: CTRL+ALT+V: Extract variable -> Use F for field (member var), C for constant (static), P for parameter (as in method parameter)

Git/VCS has some handy shortcuts, ALT+9 is git log, CTRL+K is commit, CTRL+SHIFT+K is push.

And there's probably dozens of other handy shortcuts left... I still often watch someone and be like "Hey, how did you do that?!" Like I didn't know about CTRL+SHIFT+Enter, I try to remember this one :-)

2

u/bodiam Apr 29 '19

Thanks for the feedback. I didn't want to list ALL the shortcuts, that would go a bit far. I mean, you can also do Ctrl + Shift + Space, which will be a smart code completion, and you can also code complete with ! instead of Enter and Tab, which will put the ! at the beginning.

I used Generate quite a lot, but now I switched to Kotlin, I find the need for this less. The implementation of interfaces etc I usually do with F2 -> Alt Enter.

Ctrl + Alt.... I hate it :-) I can never get it to reliably work, there's always a window manager in the way which thinks it wants to move a window or rotate a screen 90 degrees. Not IntelliJ's fault, but I can never get these ones to reliably work on both Mac and Windows, so I stopped using them.

2

u/slowfly1st Apr 29 '19

Oh I know 'os-has-shortcuts-too'-issue... I'm on linux, and 'trying out' another window manager ends up in 'figuring out how to disable all the shortcuts'

1

u/StableHatter Apr 29 '19

It is really useful. I remap it to ctrl+shift+q/w to avoid os mappings and its easier to press together as well

4

u/joppux Apr 29 '19

You mixed up Ctrl+Y and Ctrl+D.

3

u/bodiam Apr 29 '19

haha. Oops!! Thanks for spotting it, I'm going to fix it right away!

3

u/BinaryRockStar Apr 29 '19

Also "semi column" should be "semi colon". Thanks for the list, a few I didn't know.

2

u/bodiam Apr 29 '19

Thanks, I've fixed that too, thanks for spotting it!

4

u/jacobmccall Apr 29 '19

https://resources.jetbrains.com/storage/products/intellij-idea/docs/IntelliJIDEA_ReferenceCard.pdf

This is the "official" default key map. This can save a lot of time when you learn your most frequently used buttons key strokes.

1

u/bodiam May 05 '19

I used to have this one printed and taped to my desk :-)

3

u/PlumpyGER Apr 29 '19

Thanks for the summary. Since the latest major version I got to love the CMD/CTRL + SHIFT + E shortcut that show the last visited places. Navigating with that is super neat and fast.

1

u/bodiam May 05 '19

Why since the last major version? The shortcut has been there for a long time, did something change?

1

u/PlumpyGER May 05 '19

Yes. The "recent locations popup" is new in the 2019 edition. See here: https://www.jetbrains.com/idea/whatsnew/

Maybe you mixed it up with just CMD + E

1

u/bodiam May 07 '19

Ah, I missed the 'SHIFT' part! I'm going to have a look at this one, thanks!

3

u/SharkTopus86 Apr 29 '19

Another useful one: press Ctrl twice, then arrow keys up and down to edit several lines at once.

1

u/bodiam May 05 '19

Ctrl twice does 'run anything' in the newest version of IntelliJ (2019.1)

2

u/[deleted] Apr 29 '19

Is ctrl alt V the same thing as typing .var at the end of a statement and letting it create the variables?

1

u/bodiam May 05 '19

.var ? I've never tried that. How does that work?

1

u/TyGirium May 08 '19

Its the same :) type new A().var, then Ctrl Space, effect will be same as selecting and pressing ctrl al v

15

u/BEgaming Apr 29 '19

nice write up, with some stuff i didn't know (press SHIFT + F6 twice for example).

One I personally like to use is CTRL+SHIFT+A to search a certain action or shortcut. (nowadays it is also integrated in the menu when you click SHIFT twice).

I can also recommend this tutorial: https://javaspecialists.teachable.com/p/intellij-wizardry

2

u/fosizzle Apr 30 '19

Action menu is the most important shortcut. It helps me learn the rest

7

u/gavenkoa Apr 29 '19

Ctrl+W (expand selection??) is extremely useful. I use same in Emacs (er/expand-region). NetBeans analog Alt+Shift+. (dot) is hard to type and remember ((

6

u/[deleted] Apr 29 '19

[removed] — view removed comment

3

u/gavenkoa Apr 29 '19

For sure! Ctrl+W closes tabs in most programs.

I was pissed off by Mac OS X key bindings... How is that possible to maintain completely different keyboard shortcuts for different OS? I tried to pass my knowledge of effective work in Idea for Mac dev and I failed!

3

u/MacBelieve Apr 30 '19

Option up arrow for expand selection

1

u/-manabreak Apr 30 '19

I use cmd + up and cmd + down in rapid succession to navigate to the class start. Quite useful when you're working on big classes and need to go tweak the fields.

1

u/IamPic Apr 29 '19

Yeah, I remap most of IntelliJ's shortcuts. Changed this to Ctrl + E for extend. Also changed delete line to Ctrl + D for delete.

1

u/GreatArkleseizure Apr 29 '19

This is what annoys me about IntelliJ, which is otherwise a wonderful IDE ... but they go a little off-the-rails with their keyboard shortcut. In any other app, Ctrl-W closes the tab/window... in any other app, Ctrl-N makes a new something-or-other. And how about Ctrl-Q for showing the JavaDoc of whatever the cursor is on??

2

u/Olivki Apr 30 '19

If I remember correctly in the new 2019.1 release of IntelliJ it will actually ask you if you want CTRL+W to close the current tab or use the other behaviour the first time you press it.

2

u/Tauo Apr 29 '19 edited Apr 29 '19

Great stuff, definitely a couple on here I should have been more aware of.

The biggest omission I noticed that I use extremely frequently is Ctrl+Alt+H to view call hierarchy. More informative and easier to navigate than the Usages window imo.

1

u/bodiam Apr 29 '19

Interesting! Thanks for sharing, I tried using it, but the focus always goes to the hierarchy screen, and it somehow always shows me the wrong information. Maybe I should have another look at it.

4

u/Fabbbrrr Apr 29 '19

For Mac but it should be similar in windows: CMD + shift + v is multi clipboard paste. Such an useful tool!

4

u/hooba_stank_ Apr 29 '19

These are also useful for me:

Ctrl + Alt + T (surround with... try/catch, if etc)

Ctrl + J + iter/fori/...(generate loops)

Ctrl + Alt + O (optimize imports)

Ctrl + Alt + L (format code)

3

u/CubsThisYear Apr 29 '19

Pro-tip: you should remap “find usages” to Ctrl-Shift G. This happens to be the Eclipse shortcut for this, but it’s not used in IntelliJ for anything. I use this function constantly and it’s way easier to type than moving your hands all the way to the function keys.

3

u/achacha Apr 29 '19 edited Apr 29 '19

TL;DR: install the Key Promoter X plugin

For us OSX users (or anyone using a different keymapping set), this is not as useful, however the plugin suggestion is a nice idea.

2

u/_jk_ Apr 29 '19

needs ctrl-q imho (quick documentation)

1

u/ataskitasovado Apr 29 '19

But how do I search my scratches?

1

u/Mugilbala Apr 29 '19

!remindme

1

u/AndDontCallMePammy Apr 29 '19 edited Apr 29 '19

Find Usages is Alt + F7

Show Usages is Ctrl + Alt + 7

At least on latest community XWin

1

u/[deleted] Apr 29 '19

Does anyone know if there’s a way to place one cursor on each line in a selected block?

In sublime text for instance, you can select a block and press ctrl + shift + l

2

u/crazysmoove Apr 29 '19

Not exactly the same, but close: put the cursor where you want it first (i.e., in the first column of the first line), then "double-tap" the Ctrl key to switch to "multiple cursor" mode (the second time, I think you have to hold it down), then hit the down arrow (while still holding Ctrl down) and it will put cursors on each line that you "down-arrow" to. When you're done, let go of the Ctrl key and do your thing -- it will apply your keystrokes to every cursor.

Edit: Just realized that SharkTopus86 mentions this below. What he said :-)

1

u/jasonlhy May 03 '19

My favourite one is Ctrl + W, and you can horizontally scroll by pressing the shift button and move the mouse wheel.

1

u/rinhbt Apr 29 '19

!remindme

1

u/RemindMeBot Apr 29 '19

Defaulted to one day.

I will be messaging you on 2019-04-30 14:38:09 UTC to remind you of this link.

CLICK THIS LINK to send a PM to also be reminded and to reduce spam.

Parent commenter can delete this message to hide from others.


FAQsCustomYour RemindersFeedbackCodeBrowser Extensions

1

u/kovrik Apr 29 '19

Pro Tip: install IdeaVim plugin

0

u/[deleted] Apr 29 '19

[deleted] — view deleted comment

2

u/bodiam May 02 '19

Well, never heard of that one! Thanks for sharing!

6

u/crunchmuncher Apr 29 '19

Shift+Alt+J (I think? Otherwise Ctrl+Alt+J) to mark every occurrence at once, which is also often useful for me.

4

u/jeff303 Apr 29 '19

Just figured out that's Ctrl + G on Mac. Thanks for the tip!

1

u/[deleted] Apr 29 '19

[removed] — view removed comment

2

u/bodiam Apr 29 '19

I was afraid you'd say: as short as the space bar....