An overview of the


The more we use Intellij IDEA, the more powerful it is. It always surprises us when we write code. Out of my love for Intellij IDEA, I decided to write a column or series related to it and share some useful Intellij IDEA techniques with everyone. This article is the first in a series of useful tips that you may not know.


My favorite [performance mode]


We can use [Presentation Mode] to maximize the IDEA, so that you can only focus on the codes in one class and carry out coding without interference.

You can useAlt+VShortcut keys, talkViewView, then selectEnter Presentation Mode. The effect is as follows:

The advantage of this pattern is that it makes you more focused, because you can only see the code for a particular class. You might ask, what if I want to see code for other classes once I’m in this mode? At this time, will test your shortcut key proficiency. You can use CTRL+E to bring up the most recently used files. Or use CTRL+N and CTRL+SHIFT+N to locate the file.

How do I exit this mode? Simple, use ALT+V to pop up the View and select Exit Presentation Mode. However, I strongly recommend you not to do this, because you can do anything in IDEA in Enter Presentation Mode. Of course, the premise is that you are familiar with IDEA.


Magical Inject language


If you useIDEAIn writingJSONWhen you string, then you want one by one\Escaping double quotes is a bad idea, annoying and error-prone. inIDEAYou can useInject languageHelp us automatically escape the double quotes.

Place the focus inside the double quotation marks usingalt+enterKeyboard shortcuts pop upinject languageView and select

Inject language or reference.

After selection, remember to press directlyenterEnter key to pop upinject languageList. Select from the listjsonComponents.

After choosing. The mouse focus is automatically placed inside the double quotation mark, which you use againalt+enterYou can see

The selectedEdit JSON FragmentAnd press Enter to see the editJSONFile view.

You can see that IDEA does help us automatically escape double quotes. To exit the view for editing JSON information, simply press CTRL +F4.

Inject Language supports more languages and operations than you can imagine, readers can research by themselves.


Use the shortcut keys to move the dividing line


Suppose you have the following scenario where the name of a class is inprojectSomething is blocked in the view.

If you want to see the full name of the class, what do you do? You usually use the mouse to move the splitter, but this is inefficient. You can use Alt +1 to focus your mouse on the Project view, and then directly use CTRL + Shift + the left and right arrows to move the dividing line.


CTRL + Shift + Enter is not just used to add semicolons to the end of lines


ctrl+shift+enterIn fact, it meansFor you to finishIt’s not just used to add a semicolon to code. Such as:

If you type CTRL + Shift + Enter, IDEA will wrap up for you.


Don’t be tempted to use IDEA’s refactoring


IDEARefactoring is very powerful, but sometimes you don’t need to use refactoring if you just want to batch modify text within a single class. Such as:

RabbitTemplate text is used in 5 places in the code above. How to change it in batches?

The first is to usectrl+wThe selectedrabbitTemplateThis text is then used five times in turnalt+jShortcut key, check one by one, so that all five text is selected and highlighted, this time can be directly batch modification.


Get rid of navigation


Get rid of the navigation bar, because you don’t use it much.

You can remove the red navigation bar and make itIDEAIt’s a little bit cleaner and cleaner. usealt+vAnd get rid of itNavigation barCan. After removing the navigation bar, if you still need to use it occasionally, just use italt+homeYou can temporarily display the navigation bar.

To make the temporary navigation bar disappear, just use the ESC shortcut key.


Position the mouse over the Project view


When there are a lot of packages and classes in the project, we sometimes want to know where the current class is in the project view.

In the DemoIDEA diagram above, how do you know where it is in the Spring-Cloud-config project? You can use Alt +F1 to pop up the Select In View, then Select Project in the Project View and press Enter to immediately locate the class.

So how do you jump back into code from project? You can exit the project view using ESC or jump into the code using F4.


A powerful symbol


If you vaguely remember a few letters of a method name, you might want to use theIDEAHow can you do that?

Direct use ofctrl+shift+alt+n, the use ofsymbolJust look it up.

Such as:

You want to find the checkUser method. Direct inputuserCan.

If you remember a method in a business class, you can also use the first letter to find the class and add a., and then enter the method name is also ok.


How to find a directory


usectrl+shift+nAfter using/, and then enter the directory name.


Automatically generates not NULL statement


Automatic generation of not null such as if judgment, inIDEAThere are many ways to do this, one of which you may not have thought of.

After using rabbitTemplate., type itnotnullAnd press enter,IDEAI’m going to automatically generate the if judgment.


Follow the template to find the content


One of my favorites is the ability to follow a template to find a code block that matches a template. Such as:

I want to find all of the try catch statements in the entire project, but none of the catch statements do exception handling.

Catch statements that do not handle exceptions are extremely dangerous. We canIDEAIt’s easy to find all this code.

The first to usectrl+shift+AShortcut keys to pop up the Action box, then enterSearch Struct

chooseSearch StructurallyPress Enter to go to the template view.

Click the Existing Templates button and select the Try template. Set the Maximum count value of the CatchStatement to 1.

Click on theEdit VariablesButton to modify on the interfaceMaximum countThe value of the.

Finally clickfindButton to find out that there is no code inside the catch to handle exceptions.