My favorite IntelliJ idea shortcut

Time:2019-12-10

Blog: http://blog.didispace.com/int

Are you looking for more efficient programming methods? Using the keyboard instead of the mouse is not a secret, which will save you a lot of time. If you just want to perform an operation, it’s not a big deal. But what if you use the same operation multiple times a day? If you add all these operations together, it will have a great impact on your productivity.

My favorite IntelliJ idea shortcut

I do most of my work with keyboard shortcuts. When I was young, I played semi professional real-time strategic computer games, including StarCraft and Warcraft III. In StarCraft, the popular APM (operations per minute) calculates the number of actions a player performs per minute. Through the use of tools, you can record APM to determine whether the player is using the mouse operation or the combination of keyboard and mouse operation. Generally, players who use the combination of keyboard and mouse to win the game are more likely to win than those who only click through the mouse.

So what does this have to do with code and IntelliJ? Through the above examples, I believe you can think of that learning and using keyboard shortcuts to perform the required operations can effectively improve the efficiency of code development. You can view the shortcut keys on IntelliJ, or you can view the efficiency guide of your most commonly used operations through the monitor. This information is very useful, but it can be a little difficult to change your habits right away. To help you, I’ll introduce my most commonly used IntelliJ shortcuts in this article. You can familiarize yourself with these first, and then learn other shortcut keys slowly.

Statement aware selector

  • Shortcut keys:CTRL + W / CMD + W
  • Function: this can be used to select context code. It works great when you need to choose large blocks or just specific parts of a piece of code. If you have the following code:files.getFiles().forEach(auctionFile -> createAuctionFile(realm, auctionFile));, you can place the cursor atauctionFileAnd press the shortcut key, it will selectauctionFile。 Press again, the selection will expand and selectauctionFile -> createAuctionFile(realm, auctionFile)。 If pressed again, the selection will continue to expand and selectfiles.getFiles().forEach(auctionFile -> createAuctionFile(realm, auctionFile))。 Press the last time, and you will select the code completely. If you combine it with shift, you can also deselect it through context.

Recently browsed files

  • Shortcut keys:CTRL + E / CMD + E
  • Function: this will pop up a window containing the files you have recently opened in the IDE. If you enter something, it will filter by name.My favorite IntelliJ idea shortcut

Jump to declaration position

  • Shortcut keys:CTRL + B / CMD + B
  • Function: if you place the cursor in a class, method, or variable, and then use the shortcut key, you can immediately jump to the declared position of the element.

Complete sentence

  • Shortcut keys:CTRL + SHIFT + ENTER/ CMD + SHIFT + ENTER
  • Function: this shortcut key will try to complete the statement you are currently writing. How to do it? It is done by adding braces or semicolons, as well as line breaks. For example, if you have the following statement:System.out.print(), press the shortcut key once to add an end semicolon for the statement. Another example:if (condition == true), press the shortcut key to add open and closed braces, and place the cursor onifStatement with additional indentation.

Jump to class

  • Shortcut keys:CTRL + N / CMD + N
  • Function: this shortcut allows you to search java files in your project by the name you enter. If you compare it withSHIFTCollection, all files will be searched. Add on itALT, the symbol is searched. In the search area, you can use the camehumps notation (enter only the uppercase letters of the class name) to filter the files.My favorite IntelliJ idea shortcut

Intelligent type completion

  • Shortcut keys:CTRL + SHIFT + SPACE/ CMD + SHIFT + SPACE
  • Function: I didn’t mention it before, but I think you are familiar with itCTRL + SPACE/ CMD + SPACETo complete automatic completion. If you add one to the shortcut aboveSHIFT, will get more intelligent completion operation. This means that the IDE will try to match the expected type for the current context and filter all other options.

Regression

  • Shortcut keys:CTRL + ALT + ← / CMD + ALT + ←
  • Function: this shortcut key allows you to navigate back to the place where you last browsed, just like a browser. It remembers where your cursor is and even navigates to other files.

Forward

  • Shortcut keys:CTRL + ALT + → / CMD + ALT + →
  • Function: This is similar to the navigation function above, but it is “forward” navigation, not backward.

Highlight where used

  • Shortcut keys:CTRL + SHIFT + F7 / CMD + SHIFT + F7
  • Function: place the cursor in an element, press the shortcut key, and the IDE will highlight all the places where the selected element has appeared.

In addition to the shortcut keys above, there are many useful shortcut keys. Almost every operation in IntelliJ has an equivalent shortcut key. It’s very difficult for us to learn all at once. We need a certain amount of time and practice. I’m still learning new things every week. If for some reason I haven’t written code for a few days, I forget the shortcuts I’ve learned. So we need to practice, practice, practice! Try to keep learning to master them, not just in one go. It’s easy to do!

In addition, there is an IntelliJ plug-in that tells you the shortcut keys you can use when using the mouse. This plug-in is called key promoter, but unfortunately, it doesn’t seem to be maintained anymore. Maybe I can update its latest IntelliJ version. I also want to see more actions performed by shortcut keys or mouse in the efficiency guide. If I find free time, maybe I can do it.

I hope you can like it.

Note: due to the poor presentation of markdown table, the format has been modified and the original table form has not been used.

Pay attention to me

My favorite IntelliJ idea shortcut