Idiomatic IDEA

I’ve been fortunate enough to get a license for IDEA, especially after the encouragement (read nagging) by all my cow-orkers to give it a real try. I’ve been using Eclipse for 2 years and been pretty happy with it, as it does what I need, in a way that I like (or at least grown to be used to)
The version of IDEA that I have (4.5.4) has a huge improvement in things that I didn’t like about it before (CVS integration and Emacs keybindings) so I’m really looking forward to giving it a red hot go.
Now, all the IDEA users are thinking, so, why isn’t he thrilled ? Well, in a way I am, but because IDEA and Eclipse “work differently”, and I’ve been using an Eclipse mindset for so long, I’m interested to know how people use IDEA in a way that works for them.
For example, I’ve checked out a project (BouncyCastle), imported it into IDEA and changed a few files. Now, in Eclipse I can easily see in my project view which files are changed, as it will annotate the view with widgets. How do I get the same results in IDEA ? Or more importantly, how do IDEA users find out what things are changed ? I’m not trying to make IDEA like Eclipse, I understand they do stuff differently, I’m trying to learn the work habits that are more compatible with IDEA.
I tried playing with the settings in the Fonts and Colours areas, as they look like I can change the style and colours of files like this, but in the default Project and Packages view, the font colour changes, but none of the other decorations (italic, underline, background colour) appeared to have any effect.
Also, the module and project files that are created. Where do people normally put them ? In the project itself (like Eclipse, which I hated) or in a separate directory (which is what I’ve currently done).
I’m also a little confused by the “intellisense” in IDEA. I tried this;
Lis(Ctrl-space) expecting to get “List” or a box to choose from. And I got nothing. But when I typed in List and then space, I was prompted to hit Alt-Enter to fix it up. (Kinda like the Eclipse quick-fix stuff). One of the things I really liked was to have nice descriptive class names but using the Eclipse intelli-sense stuff, I could just type in a small number of characters and get it to fill in the rest.
Another great improvement (for me) was the ability to filter the Class find completions so that I could ignore java.awt.* or java.swing.* when I’m doing a J2EE project. This gets around the (very) annoying java.awt.List and java.util.List choice barfulence that Sun created. Eclipse lets me do this, how can I do something like this in IDEA.
Help me learn…… Tell me the things that makes IDEA the environment easy to work with.


21 thoughts on “Idiomatic IDEA

  1. Once I enable version control integration, I get files coloured based on their version-control status. Green for added, brown for unknown etc. To see a list of all files changed without the rest, I use “Show File View” from the version control menu. The “Commit Project” screen is cool for this too.
    I always put my project/module files in a separate directory like you did – unfortunately you need to re-choose for every new module.
    You should check out the variations of Ctrl-space.
    Ctrl-shift-space: Smart complete – only show me things that are valid in context.
    Ctrl-alt-space: Show me a list of all matching classes, including ones that are not currently imported.
    There’s even a Ctrl-alt-shift-space, which I’ve never used. You can fine tune some of this stuff in the “Code Completion” properties setup.
    Have fun, and join usssss….

  2. Thanks Daz.
    I understand the colours, but I want to make them more distinct, and by playing with stuff, I wasn’t able to. I just wondered if people have tried to make it more obvious, or most people are happy with it as it stands (latter seems likely so far)
    Why the different completion commands ? It seems kinda weird to me. How useful is it ? I find that I only need one (the Mac mouse of UI) and I’m confused that I need to think about which one to use.
    But you’ve cleared some stuff up. Tell me more, don’t just answer my questions. Tell me things I don’t even know to ask yet..

  3. Here’s a few shortcuts that I really find useful (I use the default key bindings) and use all the time (as well as all the refactoring ones):
    CTRL-E (Recent file list) – Bumped up to a really long list (Settings-Editor-Limits), this file list is colour coded (for edited/new files) assuming you have source control integrated) and you can start typing and it’ll jump to them.
    CTRL-N – Jump to class, and you can use capitals to search class names such as MLO matching MyLargeObject
    CTRL-SHIFT-N – Same as matching on classes, but different with all other resources
    I like all the live templates (iter actually works with Java 5 objects) and expand on them. I use pvt for the standard “public void testXXX” signature.
    IntelliJ’s Analyze – Inspect Code is quite powerful for good analysis with varying features overlapping/adding (perhaps even missing) in comparison to Checkstyle/PMD and Simian.
    Daz will be happy that I’ve learned many more shortcut keys since he left here as well (I’m not a big fan of the mouse), and once you get used to them, I find I can do most things without one.

  4. Use the Commit Project… dialog (Ctrl-K). It shows only the files that has changed (much like the outgoing mode in Eclipse). From here you can also do selective commits. Unfortunately there is no such thing as an incoming mode in IntelliJ which enables you to selective updates (which is really useful on a large project).
    Granted, the CVS integration is much better in Eclipse. (Of course, Darcs would be even better. *nudge* *nudge* 😉 <– Internal ThoughtWorks joke.)
    Master the different Ctrl-X-Space combinations, they are extremely powerful. The Ctrl-Shift-Space one especially. You can use it in all sorts of situations and IntelliJ will just automagically “understand” what you are trying to do. I’ve used IntelliJ for many years and I still get surprised by how much intelligence is built in. Also understand when to use Enter and when to use Tab to select a suggested completion. All this has very subtle differences to how Eclipse works. Slightly higher learning curve but once mastered very productive.

  5. Rupert Jones (a happy eclipse user) once described using trying to use Idea like wearing someone elses underwear. I kind of find the same thing when switching to eclipse.
    It can be really difficult to move to something you’re not familiar with. My advise to you is learn all the keyboard shortcuts. It’s the key to being most productive with Idea. The tips of the day are well worth reading through also.
    Regarding the ctrl-space thing. There’s a couple of reasons why it’s like this.
    1. Performance is better. This was especially true or earlier versions of Idea however later versions are much faster.
    2. Clutter. Instead of having a large list to pick from you just have what’s on context.
    It’s irritating at first but once you’ve got the combinations wired into your brain it works rather well.
    Other cool stuff… the duplication detection can actually be pretty handy. The structural search while a difficult to understand can be very handy. ctrl-shift-alt-n for symbol search.
    Case completion… ace feature. Press ctrl-n then type something like
    Will match a class DatabaseVersionChecker. Ace when you’ve got a lot of classes in your project.
    Lots more but there’s not point trying to list them all here.

  6. As an avid IntelliJ user, it staggers me the amount of times I can look the list of shortcuts,, and discover another useful feature that can be used in just a few finger combinations. For example, I just discovered what those black ticks are in the left border area that appeared through some accidental keystroke – bookmarks. Rock on!
    Some of my favorites:
    * CTRL-U & CTRL-B to navigate up and down hierarchies.
    * CTRL-[ & CTRL-] to navigate to the start and end of code blocks (especially useful on codebases littered with procedural nuggets).
    A feature I’ve long admired is it’s ability to propagate class renames down a hierarchy and change the name of variables assigned to instances of any class in the hierarchy. For instance renaming class AbstractWidget to AbstractComponent also renames class SquareWidget to SquareComponent and variable aWidget to aComponent.
    Still, Eclipse may be just as capable of performing these tasks – me no know.
    If only A.Murdoch had something to contribute to this discussion…. (internal ThoughtWorks thing again)

  7. I am glad you have finally seen the light Jon :).
    One my favourite short cuts for IntelliJ is Ctrl + Shift + Alt + N … I am not kidding. This allows you to search for a symbol name within the code base.
    I also really like the local history support in IntelliJ. Being able to see the changes that have occured locally on a selected piece of code has been very useful in the past.
    The one short cut it doesn’t have is Alt + M …that would be read my mind and do what I want. But IntelliJ gets pretty close.

  8. The Local History support, like the CVS support, is better in Eclipse.
    IntelliJ is better overall, but it’s on points in the 12th round, not a knock out in the 3rd like against most (all?) other Java IDEs.

  9. just use commit project option to see the changes. (this is available if you are working ina Version controlled environment. if it is not available, for opening this, you should go settings->version control and chose CVS or whatever first. project should be a version controlled check-out, of course.) all the changes can be seens there with a nice diff editor.
    my favorite short cuts:
    CTRL+N -> go class
    CTRL+SHIFT+N -> go file
    CTRL+E -> recent files
    Alt+f7->find usages
    Also right clicking in main and test methods for running is cool.
    The reason that “List” drop down does not appear, List is not inclueded, or in the same package level for that class. Once it is added, that drop down would appear, or use CTRL+ALT+SPACE , then it will bring all the classes in the project context starting with L.
    By default IDEA puts class files in a different directory (/classes default). IT has default web app directories too.
    Adding-removing libraries, pointing source-test directoies very easy in IDEA. And, it is faster than Eclipse. (i use Eclipse time to time, i do not deny it is a good IDE too)

  10. So, idiomatic IDEA is “keyboard shortcuts” ? I don’t think so.
    All the things described are available to me in Eclipse.
    Why is IDEA better for you ? Is it because you like it because you like it ? That’s an ok answer, and if that’s the case, I can just get on with life. However, the huge number of IDEA users that have tried to convert me from Eclipse must mean there is something about IDEA that is somehow special.
    Let’s leave the keyboard shortcuts alone, give me some work practices that makes IDEA so powerful for daily use.
    Or a simple, “well, I just like it” will allow me to sleep in peace. Or at the very least go back to WoW.

  11. I have to agree with the other “tried it, didn’t find it that exciting” comments.
    I committed myself to use IDEA for a month (trial license) and by the end of it I was really excited to be going to be eclipse.
    Pretty much everyone who loves IDEA says its because it “thinks the way they do” (or some similar idea). But it just doesn’t seem to match my thought patterns (quite possibly because they’ve been corrupted by eclipse)
    It seems to be that most people prefer whichever they used first. There’s probably some interesting psychology project in there…

  12. I’m an avid IDEA user, but I say: It’s Java, so use whatever tool makes you most productive. I personally found that IDEA is a big win for me, and I liked it better than Eclipse. (Eclipse showed its non-Java orientation pretty early – I had real trouble getting my head around where I had to look for preferences, classpath settings, etc. What a mess!) In addition to the shortcuts above, I’d add that all the control-xx-N options take ‘*’ wildcards, so you can find those ornery classes/methods. Also, alt-Enter is awesome for popping up suggestions when doing test-drivent development. Good luck!

  13. Spent over a year using Eclipse. Loved it! Then about a year ago I finally decided to see what all the noise about IDEA was about. After about a month I cringed everytime I had to use Eclipse. Why? I dunno, never have bothered to sit down and figure it out but within 3 weeks Idea clicked in a big way. Bought a personal license to make sure I always have it. I’m way more productive in it so it’s cheaper than Eclipse for me. YMMV.
    Down to one SWT app at our company and that’ll soon go.
    SWT not supporting JWS on OSX was a fatal flaw when the CEO and many others are mac users.

  14. Jon,
    I’ve noticed an interesting difference between eclipse and intelliJ users.
    IntelliJ users dont type as much code. They use the refactorings in the IDE to generate the code for them.
    An intelliJ user will often program from right to left. You think about what you want first, then let intellij do all the work to wire it into my class. I will use one of the refactorings to do this: introduce a local variable (Alt,Ctrl-V), extract method (Alt,Ctrl-M), extract parameter (this is really neat) (Alt,Ctrl-P), introduce constant (Alt,Ctrl-C), introduce field (Alt,Ctrl-F).
    A key motivator to using this is that IntelliJ is designed to allow you to “refactor” your code into shape. It is highly tollerant of incomplete statements (no annoying eclipse “missing ;” errors). And it also completes your statements (it adds in the ; for you). Note that it will guess a number of possible variable names, so I recommend using one of the suggestions. Sometimes the guesses are very smart.
    Combine the above with the smart completion, and you really should never have to type much code:
    MyFoo foo = getThatFoo();
    becomes get Ctrl-Space Enter Alt-Ctrl-V Enter and
    Result result = calculateFoos(foo, CALC_MODE_BAR);
    becomes Ctrl-Space c Enter Ctrl-Shift-Space Enter Ctrl-Shift-Space Enter Alt-Ctrl-V Enter.

  15. ah, also saving the files upon focus change is a big winner in IDEA, in Eclipse there is a similar (not default) option but when i tried it (3.0) did ot worked same as IDEA.
    it migh be a matter of habbit, but i feel like “home” with IDEA..

  16. Eclipse was written by people who knew Smalltalk, and thought in purely object-oriented ways, decoupled from the “a class is a file” orientation of Java. So of course many people don’t like it.
    Let the flame war begin… 🙂

  17. I’ve been using both for years. I use Eclipse for my personal projects and IntelliJ for commercial work. This meant that when I was based in Hemel that I would use Eclipse on the train in, IntelliJ all day and then Eclipse on the train home. This is perfectly feasible as long as you’re prepared for the 5-15 minutes it takes to slip into a different mindset.
    I can safely say that they’re both good solid IDEs. But there are things you can do without thought in either one that are so difficult as to be impractical in the other. For instance Eclipse has Problems and Tasks tabs which make it really easy for me to keep track of broken code and any FIXME or TODO comments in my codebase. In Intellij I’d have to try to compile to find all the broken classes. On the other hand Intellij makes it really easy to pick just one test and run it again and again.
    Intellij offers a much smoother user experience and all the features fit together really well for people who like to drive everything from the keyboard. Eclipse has a poorer user experience since it forces me to switch from mouse to keyboard a lot.

  18. I’m just getting back to both IDEA and Eclipse, after dabbling with them for several months, three or four years ago.
    I think the heart of why IDEA’s users love it is that IDEA was built/designed, from the ground up, to think of the source code as a structure to be analyzed and manipulated, not as a collection of files full of ASCII (or unicode) characters.
    The obvious expression of this is the refactorings, some of which Eclipse has now added to its arsenal. But the thing that IDEA junkies rave about is how this structured understanding ends up being expressed at the mundane, minutae level. How it informs all of the seemingly petty, mundane tasks that we use in a programming session – the stuff that also has keyboard shortcuts. It’s hard to explain that to somebody who hasn’t really gotten his hands dirty with IDEA, because it just sounds like you’re raving about the keyboard shortcuts. An IDEA user would, I think, agree that this a real case of synergy – the whole is greater than the sum of the parts.
    I’m an emacs junkie, myself. One thing I found nice about IDEA was that it supported dual emacs/IDEA sessions very well. The main reason I didn’t stick with IDEA was because my primary development box at the time didn’t have enough guts to run it effectively. Personally, I really want to get into scripted refactorings – imagine a regular expression syntax that was java-syntax-aware! I’m told IDEA has some pretty good scripting support.

Comments are closed.