Tips & Tricks

The real power of code completion

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: , ,

Discover more