Contents

5 + 1 tips for new IntelliJ IDEA users

Why IDEA?

It seems like a lot of people have migrated to IntelliJ IDEA over the years. As a long time IDEA user I can attest there are many reasons for that. So if you’re willing to make the jump here are some tips to ease your life.

Of course your mileage may vary, and you don’t necessarily need to agree with my opinions. That’s completely fine. 😉

Import Maven Projects like a Pro

Update
I have it on good authority that while there are differences in how projects get imported, you should not have any problems regardles of how you do it. So take my tip here with a grain of salt and decide for yourself what works best for you.

I don’t really know why that is the case but over the years I’ve found that there is one surefire way to correctly import maven projects, and it is not obvious. To import a maven project that you already have sitting on your local drive (e.g. just checked out from SCM) follow these steps:

  1. click “File” / “Open…”
  2. navigate to the project folder
  3. select the pom.xml file
  4. choose “Open as project”
  5. give IDEA some time to create the project, run its indexer etc.
/posts/idea-tips/pom_xml.PNG
Open the pom.xml

I’ve found this seems to set up a maven project correctly from the get go. All other methods of importing project like “import from existing sources” or just simply opening the project folder may end up leaving you with a non-maven project that you have to adjust manually to start the Maven integration.

Don’t ignore the Event Log

Every time something significant happens, like opening a new project, a new plugin update is available, etc. IDEA will inform the user with a small bubble like info on the lower right corner of the screen. I’ve seen people handle those as some kinds of “bad news” error message or even like spam. A lot of people seem to like to ignore whatever their IDE is trying to tell them. The problem is if you want to get the most out of your IDE you will need to pay attention to those messages.

One repeating example I see is when IDEA detects spring configurations. The IDE is super smart with code completion and refactorings if you let it know about your spring context info. It will even autodetect most if it but you as a user need to take the minute to think about whether this context info is correct or not. It usually just requires you to click on a link. Still a lot of people seem to be annoyed by the popup, don’t read it at all, never click the link, and therefore miss out on all the spring integration features.

So my tip is: look at what IDEA is trying to tell you. It will usually improve your life. Should you miss a balloon notification though, don’t worry. They are all there in what is called the “Event Log” below down right. You can still click on the links there.

/posts/idea-tips/event_log.PNG
Event Log

Forget about Workspaces

If you’ve used other IDEs before you have grown accustomed to the notion of a “workspace” folder. Usually you can add a lot of different projects to your IDE workspace and then just selectively open and close those depending on your requirements. The rough translation of this concept into IntelliJ IDEA would be like this:

common termcorresponding IDEA concept
workspaceproject
projectmodule

So one might be tempted to keep using the tried old workspace scheme, now just mapping it to IDEA projects. While this might work for simple cases it tends to get confusing fast. IDEA does not have a notion of opening or closing individual project modules. Projects really act as containers for modules that belong together in classical sense. The solution is easy: just use different projects and open those as separate windows if necessary.

Make use of the SCM Integrations

Again as if with the preceding point if you’re used to other IDEs you will usually have a bad experience with flaky or strange SCM integrations that in the best case are only a wrapper around command line tools, and in the worst case add their own idea of how to do SCM on top. The seasoned developer sooner or later learns that proper SCM invocations happen on the command line.

With “IntelliJ IDEA” you get super smart and easy SCM integrations that enable you to do complex stuff like git cherry-pick with a single button click while still enabling you understand what exactly is going on. Even if you don’t have a use for those edge cases just remember these shortcuts:

  • CTRL + t: get scm changes (e.g. svn up, git fetch && git update, hg pull)
  • CTRL + k: open commit dialog

After you mastered those two shortcuts take a look down right, you should see the current branch you’re working on. Click on that to open the super powerfull “SCM operations” popup which enables you to quickly switch branches, check out tags etc.

/posts/idea-tips/branch.PNG
Branch Info

Can’t find the SCM info in the status bar? Check your project settings and enable SCM integration. Maybe you missed a balloon popup informing you about the detected SCM and prompting you to enable the integration earlier.

The most powerful thing about the SCM integrations though is the interactive commit log view pictured below. Do people really want to call git log et al. on the command line all the time? There is literally no info the view in IDEA wouldn’t show you already.

/posts/idea-tips/git_log.PNG
Git Log

Immediately use those Keyboard Shortcuts

I know it is hard to re-train our minds to do things differently, but the key to fun in IDEA is to use keyboard shortcuts. You should use the following ones immediately from the start:

KeysAction
CTRL + Wsmartly increase text selection (just try it out)
F2jump between problems in the current file
ALT + ENTERfix problem at cursor (may open context menu to chose the fix to apply)
CTRL + SPACEforce invoke intelli sense
CTRL + SHIFT + SPACEinvoke smart intelli sense
CTRL + ALT + SPACEcomplete current word context sensitively (if it is a class name add the fully qualified package etc.)
CTRL + V / CTRL + M / …extract variable / method etc. (or use postfix completion like .var instead)
CTRL + Qshow documentation for type at cursor
CTRL + Hshow type hierarchy for type at cursor
SHIFT + F6rename thing at cursor
STRG + F6refactor thing at cursor
STRG + F1tell me more about the current problem
STRG + Nopen class
STRG + SHIFT + Nopen file

Keep Learning

I’ve been working with IDEA pretty much every other day for more than a decade now. One would expect me to have mastered it by now. That couldn’t be further from the truth though. One thing is that the people at JetBrains are still coming up with new ideas of how to improve their IDE, so the development never stops. The other thing is that a lot of really cool and pro functionality is usually not easy to find. Just today I discovered that the built in markdown support can even use PlantUML diagrams, if setup correctly…

So definitely keep the “Tip of the day” enabled. You will learn new things every day. And on top of that think about maybe enabling plugins like the “Key Promoter”, this will teach you what keyboard shortcuts you could have used to achieve whatever you just did by using the mouse.

  • “JetBrains”, “IntelliJ IDEA” and the IntelliJ IDEA Logo are trademarks and property of JetBrains.