It’s always a great idea to try and master the tools with which you work. I’m on a mission to improve my IntelliJ skills and have been watching and reading tutorials on IntelliJ tips and tricks. One of the very best I’ve come across so far is this video by Hadi Hariri. As well as being very informative it is also entertaining and Hariri’s presentation skills make the video anything but boring. I encourage you to watch the video when you have a spare hour.
Hariri, basically challenges IntelliJ users to take on these challenges:
- Use IntelliJ without touching your mouse.
- Use IntelliJ with only one open tab.
To use IntelliJ without a mouse requires mastery of keyboard shortcuts. Once you’ve learnt them you will find that it’s way more productive than taking your hands off the keyboard and fiddling with your mouse. I’ve tried really hard to manage completely without a mouse forcing myself to learn the keyboard short-cuts. It’s actually really difficult – but worth it. I can’t say I’ll ever get to the point where I won’t use the mouse at all but if I can get my most frequent mouse operations down to fast keyboard short-cuts I would consider that mission accomplished.
Using IntelliJ with just one tab (this can be configured in preferences – search for ‘tab limit’) is a very interesting idea. I’ve been working on this for a couple of weeks and it actually makes a lot of sense. My preferred coding configuration is to maximise the editing area (
CNTRL SHIFT F12) and then split the screen vertically (right click on the tab header). In this way I can see the code I’m working on as well another class.
The following table summarises the tips, tricks and keyboard shortcuts that were presented in the video, many of which I use frequently when attempting not to use my mouse. Some of these will be known to pretty much anyone who is not an IntelliJ novice but others are more obscure and all are pretty useful.
All the key bindings in this table are for MacOsx 10.5+. To bring up the key bindings menu enter
CNTRL ~ for obvious reasons this command is the same for all key bindings.
|SHIFT CMD||a||Find keyboard shortcut|
|CMD||o||Open a type||Type in Camel case letters for search|
|CMD SHIFT||o||Open a file|
|CMD ALT||o||Open a symbol|
|CMD||1||Focus project explorer||Esc focus back in editor|
|SHIFT SHIFT||Search everywhere|
|CMD||F12||Show class members||CMD F12 again to show inherited members|
|F4||Move from project window to editor|
|CMD||e||Recently viewed files|
|SHIFT CMD||e||Recently edited files|
|CNTRL||TAB||Switch to last viewed window forwards|
|CNTL SHIFT||TAB||Switch to last viewed window backwards|
|CNRL||b||Go to type declaration|
|CMD||y||View type declaration|
|ALT CMD||b||View all implementations|
|CMD||[||Go back to last cursor point|
|CMD||]||Go forward to cursor point|
|CMD SHIFT||F12||Maximise editor||CMD SHIFT F12 to toggle back|
|CMD CMD||Show all windows (if they are hidden)|
|SHIFT||F4||Extract the editor as new window|
|CMD SHIFT||RIGHT ARROW||resize project window wider|
|CMD SHIFT||LEFT ARROW||resize project window narrower|
|ALT||UP ARROW||semantic selection increase|
|ALT||DOWN ARROW||semantic selection decrease|
|ALT SHIFT||UP ARROW||move highlighted code up|
|ALT SHIFT||DOWN ARROW||move highlighted code down|
|CMD||d||duplicate current line|
|CMD||BACKSPACE||delete current line|
|SHIFT||ENTER||insert new line under current|
|ALT SHIFT||ENTER||insert new line above current|
|ALT SHIFT||MOUSE CLICK||multi caret support|
|CNTRL CMD||g||multi carti selecting each instance|
|CNTRL||g||move to next instance of highlighted|
|CNTRL SHIFT||g||move to previous instance of highlighted|
|ALT CMD||l||code reformatting|
|CMD||w||closes a tab|
|CNTRL SHIFT||SPACE||smart code completion|
|CNTL ALT||v||introduce a variable|
|ALT||ENTER||General help and useful completions||e.g. create Test and fix errors|
|F2||Go to next error or warning|
|SHIFT||F2||Go to previous error or warning|
|CMD||r||Search and replace|
|ALT||F12||Bring up a terminal|
|CNTRL SHIFT||r||Run this class|
|CNTRL SHIFT||d||Debug this class|
If there are any other useful ones that you use frequently please let me know and I’ll add them to the list!
A few other notes of interest:
- Help -> Productivity Guide keeps track of what you do and by sorting on the functionality that you have not used can show you functions you probably didn’t realise were available.
- Help -> Default keyboard reference gives you a full list of keyboard short cuts
- Post fix completion is fantastic. e.g. if you have an int i type i.fori to generate a for loop. Or if you have an Object obj type obj.notnull to generate a null check. There are loads of other to investigate like try which generates a try catch.
- If you are demoing or pair programming and want people watching to see your keyboard shortcuts use the presentation assist plugin which will highlight your keyboard shortcuts on the screen.
- View -> PresentationMode makes your code much bigger and also useful for demos.
- The gears icon in the project explorer allow you to automatically scroll from the project window to the editor view and visa versa. I always select those options. You can also select to see methods as well as classes in the project window.
Hope you found this useful and that taking on the IntelliJ challenge improves your productivity. Please use the comments section for your favourite IntelliJ tips.