The Kaptain on … stuff

18 Aug, 2009

My Favorite IntelliJ Resources, Tips and Tricks

Posted by: TheKaptain In: Development

Today at work I was reminded that I didn’t learn how to use my IDE overnight, and that I’ve been greedily hoarding where I found good resources for learning how to drive IntelliJ in the fast lane. So without further ado, here’s the top places I’ve found and things I know.

Links on the IntelliJ site:

  1. 1. The main documentation page
  2. 2. Demos and tutorials including a couple of new Groovy support demonstrations
  3. 3. 25 things you can do with IntelliJ 8 you can’t do with 7
  4. 4. Mac Keymap reference
  5. 5. Windows/Linux keymap reference
  6. 6. The Jetbrains IntelliJ blog. A great way of getting tips from the guys that wrote it, and keeping up to date with improvements.

DZone: Intellij in 7 pages

  1. 7. The DZone refcard for Intellij

My personal faves

  1. 8. Command Shift-A to bring up a search window for actions. This one I think of as Quicksilver for my IDE.
  2. 9. Alt-Enter to trigger intentions. Problem with your code? Let the IDE suggest a refactor to correct it.
  3. 10. Ctrl-n for auto-generation of Java code. Getter and setter boilerplate getting you down(and you can’t switch from Java to Groovy)? Want a nice compact toString() on a class with 20 member variables? Let the IDE do the heavy lifting.
  4. 11. The Javadoc Sync plugin. This goes well with #10 to javadoc all those getters and setters auto-magically.

Add logging using the debugger

  1. 12. Printing to the console is a basic tool for debugging code. Everybody’s done it – because it’s easy and it works. But you often come across scenarios that disallow this quick and satisfying hackish behaviour. Namely when you are debugging into code in a library, this is not necessarily an easy option. Fortunately IntelliJ provides a nice easy way to add console logging through the debugger. You can access the breakpoint configuration dialog either by right clicking on an existing line breakpoint and selecting ‘Properties’ or by pressing Command Shift-F8 from the Debug view. From there you configure your line or Exception breakpoint with a ‘Suspend policy’ of ‘None’ and check the boxes under ‘Actions’ to enable logging. A full description of the features can be found here.

    I find this especially handy when there’s a problem iterating over a Collection and only one or some of the items in that Collection lead to an error condition during processing. Using this strategy I can provide context as to which cases passed and which failed without having to stop at a bunch of breakpoints and inspect the variables on the stack; I can just concentrate on the failure point and look back at the console output to compare against previous invocations.
    Here’s a couple of screencaps to show configuration for logging the size of a list on a line breakpoint. Note that the Groovy requires a little bit of extra magic, since the debugger gets passed a Reference object instead of the raw List.

[nggallery id=”6″]

Bonus from the Community

  1. 13. Grails returning the favor for the great IntelliJ support.

How about you?

  1. 14. Do you know any other good places to learn about IntelliJ and how to get the most out of it? Please don’t keep it to yourself! I managed to line up a baker’s dozen, now you’re on the hook for number 14 smart guy.
Reblog this post [with Zemanta]

6 Responses to "My Favorite IntelliJ Resources, Tips and Tricks"

1 | Ashitkin Alexander

August 21st, 2009 at 10:14 am


IDEA the best. I enjoy it everyday and everyday i discover something new and interesting.

2 | Manfred Moser

August 28th, 2009 at 7:52 pm


The only thing I would add is that using the EAP versions is many times really worth the new features and generally they are quite stable.

3 | jer

September 2nd, 2009 at 7:08 pm


Ctrl-n? Have you changed the default keyboard shortcuts? By default Alt-Insert will show the code generation options.

Nice article, though. I didn’t know about ctrl+shift+a.

4 | TheKaptain

September 2nd, 2009 at 10:57 pm


No changes to the defaults – at least not any that I can remember doing offhand. I am however on a Mac, which might be the difference. And I’m pretty sure I picked on that cmd+shift+a from the IntelliJ dev blogs – all the secret goodies to squeeze productivity out of the platform.

5 | Dave Lorde

September 17th, 2009 at 12:37 am


Ctrl-n is the default ‘Find Class’ command…

A useful extension to the debugger ‘log expression’ breakpoint facility is that not only can you evaluate expressions and output the results, but you can call methods and assign results to program variables, allowing you to temporarily ‘fix’ problems or try ‘what-if’ scenarios on-the-fly while debugging, without stopping or having to hack your code, and still get full console logging of exactly what you did.

The alt-F8 debugger expression evaluator dialog allows you to execute whole chunks of code while debugging, and can also change program variable values, but needs you to be stopped at a breakpoint.

6 | TheKaptain

September 17th, 2009 at 6:38 am


Thanks Dave. Indeed the ability to evaluate expressions on the fly, and to just generally mutate the stack at runtime, is VERY handy for testing and debugging. And just this week I saw this article over on JetBrains for Debugger Evaluate Expression Enhancements – so it’s just going to keep getting better it looks like.

Comment Form