The real power of code completion

Posted on by alexandra.rusina

Code completion is now a must for each and every IDE. But are you using all its power in IntelliJ IDEA? Check out the tricks below to get the answer.
Complete variables names
How often do you need to declare something like ArrayList list? Using Ctrl + Space you can complete the name of the variable. In this example, you will be suggested to choose between arrayList and list names.

Use “CamelHump”
Probably, you already used “CamelHump” for navigation and search. But it works for code completion too. Everything you typed in the editor will be replaced with the relevant code.
CamelHump Completion
Replace expressions
For example, you have the following expression:

myFrame.setPreferredSize(new Dimension(800, 600));

And then you decided that this should be the minimum size. The fastest way to change this code in IntelliJ IDEA is to place the caret after the dot, then press Ctrl + Space. Find the setMinimumSize() method (don’t forget about “CamelHump”!), and press Tab.

The setPreferredSize() method will be replaced with the setMinimumSize(). Don’t worry about your parameters – they will stay where they are.

There are more tricks in IntelliJ IDEA related to completion (such as smart completion) that will be described in the future blog posts. But if you don’t want to wait, check out the Productivity Guide in IntelliJ IDEA or see description of java code assistance features.

Note   This tip&trick was originally posted at www.javalobby.org.

Technorati tags: , ,
Comments below can no longer be edited.

3 Responses to The real power of code completion

  1. Deril says:

    April 27, 2010

    Thanks for post.
    Currently I am trying InteliJ.

    these features is nice and handy in lot of situations..

    but.. in ALL situations you will be writing code and real power of auto-completion comes then it speeds you no matter what you type. Hare is my 2 most important auto-completion features… (I am in love with them so strong that I have trouble with any tool that don’t support them.)

    1 – auto-completion ASAP !!!
    that means you don’t have to press Ctrl+Space, application does it for you, it assumes you press it after ANY 2 letters and more are typed. it doesn’t wait for dot.. it doesn’t wait for ctrl+space. After first 2 letters are typed it starts hinting you in document scope, and if you press ctrl+space… its hints you in document+framework scope.
    its speeds productivity so much.

    2 – substring hinting, – (not only start of the method or function.)

    imagine you have 3 methods… varLoad, xmlLoad, xmlParse. you can choose to type “xm” to get last 2 methods hinted… or start writing “lo” for “load” and have first 2 methods hinted…
    again.. huge speed improvement. in not only removes the stress to remember how elements start, it gives possibility to communicate what you are trying to write with as less key presses as possible.

    and then you are in ‘typing’ business… every key press counts. 😉

    does InteliJ has these powers? or plugin? or it su#s on that same way as eclipse…

  2. Agree with Deril says:

    June 13, 2010

    In total agreement with Deril.

    I am testing Intelij right now and am impressed, but having to press ctrl-space (which I’ve been using for years for Quicksilver) just to view possible suggestions is enough to make me look elsewhere.

    I need an IDE that I can crank out code in, not one that slows me down…

  3. yanglikun says:

    September 30, 2016

    Replace expressions
    not work for me!

    myFrame.setPreferredSize(new Dimension(800, 600));
    change to
    myFrame.setMinimumSize();setPreferredSize(new Dimension(800, 600));
    need manual modify

Subscribe

Subscribe for updates