IntelliJ Tricks

Nishant Madan
Nov 13, 2019 · 6 min read
Photo by Juan Gomez on Unsplash

This blog is for people who are already aware or previously working on IntelliJ and want to learn some of the shortcuts to save their precious time while doing the development or while giving talks.

As we all know shortcuts save a lot of time, when it comes to coding, keyboard is always faster than a mouse. One of the studies shows that shortcuts saves about 1–4% of the entire time of your coding which in my precepts is really invigorating.

This tour will give you very essence of cool stuff which IntelliJ supports and I believe that you all will agree that it will boost your productivity when you learn some of the feature sets that it is famous for.

Configuring Plugins

The reason I find this part to be the first to cover as it is one of the things an orator must know while giving the talk on IntelliJ shortcuts and your viewers might want to know the shortcuts for all the systems whether it is Mac/Windows/Linux. In the Settings/Preferences dialog (Ctrl + Alt + S) to navigate to settings and then use the arrow keys to switch to plugins if not on that option.Now search the name of the plugin you wants to install in my case it is “Presentation Assistant”. After successful installation restart the IDE as shown.

Configuring Live Templates

The motive to configure the live template is to make the repeated code as a template in the system and then re-use the code by applying the keyword which you have configured against that template. So if you want to add live template to your project then navigate to Settings/ Preferences dialog (Ctrl + Alt + S) and then select the group in which you want to add the repeatable code or make your own template group by pressing (Alt + Insert) and then press 2 .

Another way of configuring the live template is to select the piece of code or line of statements and then press (Ctrl + Alt + T) then you will get the option to configure that segment to live template.

Then after configuring the template group just copy the piece of code you want to apply for the live template by pressing (Alt + Insert) and then press 1.

Then just click on define to configure for which language you want to apply that template if you wish you can select multiple options and then you are ready to use the template in that language.

Artifacts

To configure the artifacts in your project, navigate to Project Settings (Ctrl + Alt + Shift + S) and then use up/down arrow key to navigate to artifacts option and to add the method of artifact press (Alt + Insert).

An artifact is an assembly of your project assets that you put together to test, deploy or distribute your software solution or its part. So one should also need that part in their project.

Generating Test Class and Creating Child Class

Using (Alt +Enter) one can generate the test class for the current class in the src->main->java directory in the src->test->java directory by-default or one can also use (Ctrl + Shift + T) to directly generate the test class in the test directory.

This is really one of the cool features of intelliJ that you don’t need to create another directory and make the directory test compatible and then add the <class_name>test.java file to that directory that shortcut do the whole stuff for you and you do not need to take care of anything.

It will also be helpful if you want to add your current class as the parent for some another class by choosing the “create sub-class” option. In that case you just need to specify the name of the child class and it will create the class extending the current class in the same package or directory.

Refactor Suggestions

This can be achieved with the catchy magic incantation (Ctrl+Alt+T) and (Ctrl+Shift+Alt+T) . IntelliJ is intelligent enough that if you wants to refactor your code it will give you suggestions by reading the current context of the code. It is useful as sometimes the developer won’t know what refactoring should be done in the given context. For example, if you wants to surround the given piece of code in the loop or if/else statements.

Similarly if anyone wants to rename the method(s)/variable(s) name then press (Shift+ F6) to do the task.

Rearranging Method parameters

What I didn’t know about IntelliJ is that it also supports the shortcut to rearrange the method parameters. Once I was in trouble with too many arguments in the method to re-arrange then I found that shortcut so one can achieve the re-arranging done by pressing (Ctrl + Alt + Shift + Left (<-) or Right (->)). So it’s really quick and simple you all will find that it is easy to use.

Navigating Around the Code

If we are writing the code and in-between we wants to search for things that we don’t know where in the IDE is for instance if we are looking for the presentation mode to be open and we don’t know how to do that then we can go to Actions tab by pressing (Ctrl + Shift + A) and type what we want to search for.Now let’s see some of the shortcuts how we can navigate around the code.Now let suppose we want to look for any file in the system then navigate to All tab by pressing (Shift twice).

Summary

We learn a bit about IntelliJ shortcuts in this journey and obviously this is not enough about the shortcuts. So, the focus is to keep learning about things so that the more you use the system more you will get the exposure to the shortcuts. A good programmer should always keep on learning new things and after years of doing programming, we adopt new and exciting shortcuts in IntelliJ.

Be productive.

Nishant Madan

Written by

Xebia Engineering Blog

The Xebia Engineering Blog

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade