IDEA's commonly used operations to improve efficiency

IDEA is currently one of the most widely used Java development tools. Although it is charged, it also provides a free community version, and the paid version also supports open source projects using github, using a free license. Although it must be renewed every year, I The free license applied for by the open source project is used.

During the development process, there will be many shortcut keys, plug-ins, views, configurations, etc. to improve development and debugging efficiency, and often every two people understand different efficiency-enhancing operations. Sometimes, I will be surprised when I accidentally see other people's operations, and there are such operations.
This article tries to record the efficiency-enhancing operations I have learned:

1. Related to shortcut keys

Note: If you find that the following shortcut keys are not available in IDEA, after confirming that you have not modified them, they are usually occupied by other programs:

  • The input method uses this shortcut key, and the Baidu input method used before used it
  • QQ occupation
  • WeChat PC version

1. Definition of transfer method

Ctrl + left mouse button

  • Click on the method to go to the definition of the method
  • Click on the variable, it will go to the definition of the variable
    Note: If you enter the decompiled code, you can click [Download Source Code] in the upper right corner to see the normal code with comments

2. Implementation of transfer method

Ctrl+Alt+left mouse button

  • Click on the method, if it is an interface or parent class method, it will jump to the implementation of the subclass;
    if there are multiple subclass implementations, a list will pop up, allowing you to select one of the implementations and then jump over.
    Note: I didn’t know this shortcut key before. Every time I have to go to the interface first, and then click the small green arrow on the left side of the interface to realize it. Sweat...

3. A list of overridable methods pops up

Ctrl+O
is in a class, press this shortcut key, a list of all methods that can be Override in the current class will pop up, such as:
insert image description here

4. Quick format code

Ctrl+Alt+L
will automatically format the code of the current file, please consciously develop this good habit.
Note: I have developed a habit now. When I write some code, I just press the shortcut key, even in Notepad, Word, etc. I often press it, and I find something wrong after pressing it...

5. Global search

  • Press shift twice, a global search window will pop up, you can search for any content: class, method, string, Controller route
    insert image description here
  • Press Ctrl+Shift+F to pop up the global string search window
  • Press Ctrl+Shift+R to pop up the global string replacement window

6. Pop-up comments

Ctrl+Q
pops up the annotations of the class, method, and annotation where the mouse is located, for easy reference

7. Quick wrap around code

Ctrl+Alt+T
select a piece of code, press this shortcut key, put try/catch or if/else, while on it:
insert image description here

8. Fast packaging method

Ctrl+Alt+M
select a piece of code, press this shortcut key, you can extract this part of code as a private method

9. Quickly generate temporary variables

  • Select part of the code, press Ctrl+Alt+V, you can convert this part of the code into a temporary variable assignment and replace
  • Select a part of the code and press Ctrl+Alt+Fto convert this part of the code into a private variable of the class to assign and replace
  • Select a part of the string or value, press Ctrl+Alt+Cto convert this part of the code into a constant value and replace it

10. Display all methods of the current class

Ctrl+F12
The pop-up window displays all the methods of the current class, especially when there are many lines in the file.
Alt+7
fixedly displays all methods of the current class on the left

11. Display history pasteboard

Ctrl+Shift+V
displays the list of historical copy, you can choose to paste

2. Plug-in related

1. Dependency viewing and positioning plug-ins:Maven Helper

After installing this plug-in and opening pom.xml, you can switch to the dependency tree interface and enter keywords to find the package, and you can also right-click to jump to the location where the package is referenced:
insert image description here

2. Hot deployment plug-in:JRebel

IDEA does not support hot deployment by default. If you modify the Java source code or html file, you need to restart the project by default to take effect, and some projects start for tens of seconds or even longer, which is a waste of life.
The JRebel plug-in can support that after saving the modified code, it will take effect automatically in about 5 seconds.
It should be noted that this plug-in is only free for 14 days, and you will be charged after it expires. Of course, there are many cracking tutorials on the Internet, look for it yourself, haha.

3. View related

1. Service view

Click [View] => [Tool Window] => [Service] in the menu bar, and in the opened view window, click + => [Run Configuration Type] => [SpringBoot] to automatically load the currently opened SpringBoot project.
Function: When starting the SpringBoot project in IDEA, the [Run] view was opened by default, and the [Debug] view was opened by default for debugging. But every time I forget which port this project uses, and I have to manually open the browser to enter the url.
Later, I accidentally discovered that IDEA has this view. You can directly click on the port to automatically open the url from the browser:
insert image description here

2. Quickly locate the location of the file in the project view

After IDEA opens a file, [Project View] will not display the location of the file synchronously.
At this point, you can click the circular positioning button on [Project View] to quickly locate:
insert image description here

3. For multi-module projects, the specified directory is configured as a Maven project

A normal Maven project will display a small light blue square, and it can be built and started in IDEA:
insert image description here
Sometimes, for some reason, the small square is gone, and the project cannot be started, and an error will be reported.
At this point, click the plus sign in the Maven window on the right, and then select the corresponding directory pom.xml:
insert image description here

Four, configuration related

1. Mouse + scroll wheel to modify the font size

insert image description here

2. Automatically import appropriate packages and optimize unnecessary packages

insert image description here

3. The code interface displays line numbers and line breaks between methods

insert image description here

4. Code completion prompt ignores case

By default, code completion will be case-sensitive, enter lowercase s, and will not prompt String, you need to set this to uncheck:
insert image description here

5. When creating a new file, automatically add comments

Refer to the configuration in the figure below, the newly created Java file will automatically have comments
insert image description here

Guess you like

Origin blog.csdn.net/youbl/article/details/130393139