Intellij Idea without a mouse

I decided to write this post after watching Hadi Hariri’s talk at Geekout 2014 called “Mouseless Driven Development
According to Hadi, it is possible to code in Intellij Idea without even touching a mouse. I can believe it.
In the post I am going to present some nice tricks which I use on my daily work with Intellij Idea and the new ones that I learned during the talk.
Writing this post I was using Intellij Idea 13 so some of the shortcuts may not be available in the older versions.

  • CTRL+N – brings a class name finder. You can type camel case and it finds the appropriate class. However it is also possible to put colon after the class name followed by a number and it takes you to the class and goes to the line specified by the number entered.

i1

  • CTRL+SHIFT+N – brings a file name finder which you can use in the same way as CTRL+N.
  • CTRL+SHIFT+ALT+N – brings a symbol finder.
 i2

As you can see there are a few consumeFloat() methods and if you want to go to the particular symbol name you enter class name before the symbol:

i3

  • double SHIFT – brings a “Search Everywhere” window, search not only classes and files but you can look for some settings.
i4
  • ALT+1 – goes to Project Explorer and like in any other window or toolbar you can actually type letters and that finds an appropriate item.
i5
  • CTRL+F12 – brings a popup which allows to navigate to different symbols/methods in the current file or class.
  • CTRL+E – brings a popup with the recent opened files.
  • CTRL+SHIFT+E – brings a popup with the recent edited files.
As far as two above shortcuts are considered I would like to add some more information. Particularly, they allowed me to completely get rid of tabs in Intellij Idea. I realized that using the shortcuts I do not need them any more. They have been only introducing a mess since nearly every time I needed to change a tab I had to look for a specific one among many of them currently opened. When I started using lists of recent and recently edited files going to previous files got far more easier.
  •     CTRL+TAB – allows you to switch to different windows, etc.
  •     CTRL+B – when cursor is placed on the item in the class, it takes you to the declaration.
  •     CTRL+ALT+LEFT/RIGHT – allows you to go back and forward where you have been before.
  •     CTRL+SHIFT+I – brings a quick popup window with an item definition.
i6
  • CTRL+ALT+B – goes to the implementation if there is one or displays pop up with all implementations available.

When navigating between files in the project explorer with UP/DOWN keys you can press ENTER and it shows a current item in the editor without moving focus to the editor. However, F4 pressed opens item in the editor and moves focus to that editor. Very efficient way to navigate through project without touching a mouse.

  • CTRL+ALT+F7 – brings a quick pop up showing usages of the current item in the project.
  • CTRL+SHIFT+F7 – highlights usages of the selected item; when used on the throw it highlights all the places in the current method where the exception is thrown; when used on the return statement it shows all the places where the method exits.
  • CTRL+SHIFT+F12 – hides all opened windows and maximizes the editor, entering shortcut again brings the closed windows back
  • CTRL+SHIFT+LEFT/RIGHT – entered when you are in the project explorer it resizes the editor; very nice feature – give it a try.
  • CTRL+W – expands context sensitive selection.
  • SHIFT+ALT+UP/DOWN – moves text up and down; it is context sensitive so where you place cursor on for loop for instance it moves up and down the whole loop.
  • CTRL+SHIFT+ENTER – intelligently completes current statement (for example adds semicolon at the end of the statement).
  • CTRL+ALT+T – brings a “Surround With” popup which gives you a few options of code insertions; works not only for Java but for other technologies (HTML, etc.) as well.
i7
  • CTRL+SHIFT+SPACE – smart completion which filters the list of available methods or variables to match the expected type.
What we still do, even if they are better ways to handle such cases, is checking if a variable is not null.
In Intellij Idea you do not have to write the same statements again an again. Having an object variable, put dot and the end and press CTRL+SPACE or CTRL+SHIFT+SPACE or CTRL + J and on the list there is an option “notnull” which generates that cumbersome statement for you.
  • CTRL+J – inserts a live template; the shortcut is context sensitive and gives you different options when pressed on the variable or for example in an empty space in the editor; even if you not defined your own templates, those built in are worth looking at.

i8

  • CTRL+SHIFT+ALT+T – brings a refactor popup; unfortunately it is not context sensitive.
  • SHIFT+F2/F2 – goes to the next/previous highlighted error, however it works that way only if the following option is checked in:

i9

  • ALT+F12 – opens operating system terminal inside IDE.