Set up the following Idea configurations to greatly improve R&D efficiency

Here are some suggestions for configuring IntelliJ IDEA, which can improve development efficiency:

1. Customize code style (Code Style), unify project code style

In IntelliJ IDEA, you can customize the code style, mainly including:

  1. Set the indentation rules of the code, such as: the number of indented spaces, whether to use spaces instead of tabs, etc.

Configure in Settings - Editor - Code Style - Java.

  1. Set the style of brackets, such as: curly brackets, line breaks, etc.

Configure in Settings - Editor - Code Style - Java - Wrapping and Braces.

  1. Set the head style template of comments, such as: function comments, etc.

Configure in Settings - Editor - File and Code Templates.

  1. Set the case rules of words, such as: class name uppercase, method name lowercase, etc.

Configure in Settings - Editor - Code Style - Java.

  1. Sets a newline character (\n or \r\n).

Configure in Settings - Editor - Code Style - General.

  1. Set the encoding format to UTF-8.

Configured in Settings - Editor - File Encodings.

  1. Set code prompt options, such as: display parameter names, etc.

Configure in Settings - Editor - General - Code Completion.

  1. Set save to automatically remove trailing spaces.

Configure in Settings - Editor - General.

By customizing these rules, the code style of the project can be more consistent, conform to the specification, and improve readability and maintainability

2. Adjust the editor font size and code color theme to optimize the reading experience.

3Enable the function of automatically importing packages (Opt+Enter) to optimize the operation of importing packages .

Proceed as follows:

  1. Open Settings, go to Editor -> General -> Auto Import
  2. Check the "Optimize imports on the fly" option
  3. Check the "Add unambiguous imports on the fly" option
  4. In Code, when the red unimported class appears in the statement
  5. 按 Alt + Enter (Option + Enter on Mac)
  6. Select the Import class option

At this point, the automatic package import function is enabled.

In addition, you can also configure automatic optimization of imported packages:

  1. Open Settings, enter Code Style -> Java -> Imports
  2. Check the "Optimze imports on the fly" option
  3. Check the "Add unambiguous imports on the fly" option
  4. Set "Optimize imports on commit" as required by the project

In this way, when the code is submitted, the imported package will be automatically optimized, and the introduction of useless packages will be deleted.

4. Turn on the method parameter prompt function, and the parameter information can be prompted when calling the method.

Proceed as follows:

  1. Open Settings, go to Editor -> General -> Code Completion

  2. Check the "Show parameter name hints" option

  3. When calling a method in the code, enter the left parenthesis of the method name, and the method parameter information will be displayed

  4. Enter the calling parameters according to the parameter prompts to realize quick calling

5. Multi-project development, you can configure different JDK, Maven parameters, etc., to distinguish the project environment.

6. Use with database plug-ins

Commonly used IntelliJ IDEA database plugins include:

  1. Database Navigator - database browser, you can browse the database table structure.
  2. SQL Dialects - Supports syntax highlighting for various SQL dialects.
  3. Connection Manager - A database connection manager that can manage different database connections.
  4. SQL Generator - SQL statement automatic generator, which can generate CRUD statements according to the table structure.
  5. Query console - query console, you can run SQL statements directly in the IDE.
  6. Table Editor - Table data editor, supports visual editing of table data.
  7. Database Tools and SQL - Integrated database client tools.

Using these plug-in functions, you can avoid switching database client tools back and forth, and complete database operations directly inside the IDE, greatly improving work efficiency.

7. Set code auto-completion and smart prompt

In Preferences (Mac) / Settings (Windows), go to Editor -> General -> Code Completion and make sure that automatic code completion and intellisense are enabled.

8. Use shortcut keys

Familiar with and use the shortcut keys of IntelliJ IDEA, such as Ctrl + Space for code auto-completion, Ctrl + Alt + L for formatting code, etc. This will help speed up coding.

9. Custom templates and Live Templates

  1. Open Settings, go to Editor -> Live Templates

  2. Click the "+" sign on the right and select Live Template

  3. Fill in the Template text in the pop-up window, which is the content of the code template

  4. Fill in the Template description to explain the purpose of this template

  5. Define Applicable in, where this template can be used

  6. Use VAR VAR in Template text contentV A R defines variables

  7. Define the meaning of these variables in Edit variables

  8. Click Define to complete template creation

  9. Enter the template Abbreviation in the code to insert the template

10. Import and manage external libraries

Use IntelliJ IDEA's built-in functionality to import and manage external libraries. You can use Maven, Gradle or manually import jar files to manage project dependencies.

11. Configure version control

Integrate your project with a version control system (such as Git) and perform the necessary version control operations on the project. This will help with team collaboration and code management.

12. Plug-ins and extensions

Depending on your needs, install and use the plugins and extensions that fit your workflow. There are various useful tools and enhancements in IntelliJ IDEA's plugin library.

13. Use refactoring features

  1. Rename - Modify the names of classes, methods, variables, etc., automatically find references and modify them together.
  2. Extract - Extract code into new methods, variables, parameters, etc.
  3. Pull Members Up - Promotes the members of the class to the parent class.
  4. Push Members Down - Move members of the parent class down to the child class.
  5. Inline - Inline method calls as method body code.
  6. Change Signature - Modify the method signature, including name, parameters, etc.
  7. Move - Move a class, method, field, etc. to a new location.

The main steps to use refactoring:

  1. Right click on the code and select Refactor > Refactoring method
  2. Preview refactoring changes comparison in popup window
  3. Perform refactoring after confirmation

It should be noted that you must first ensure that the project has no compilation errors, otherwise some refactoring functions will not be available.

14. Configure code analysis and inspection

Configure code analysis and inspection features based on project specifications and personal preferences to ensure consistent code quality and style.

Code analysis can be configured in IntelliJ IDEA, mainly including:

1. Turn on code inspection

Open the required inspections in Settings - Editor - Inspections, such as: unused variables, methods, etc.

Some problems can be found instantly while writing code.

2. Configure code analysis scan range

In the Inspections window, scan Which files to scan through Scope settings, and you can specify directories such as src or test.

3. Set the scan frequency

In the Inspections window, set the scanning frequency through the Inspection profile, such as: HTMLParsers While idle means scanning when saving.

4. Ignore specified checks

For some inspections that you do not want to open, you can right-click in the Inspections window to remove the check.

5. Check the test results in real time

In the Analysis Result tab in the lower right corner of the window, you can see a list of detected problems.

6. Fix problems with one click

In the Analysis window, one-click Apply Fix to fix problems that can be automatically fixed.

Configuration code analysis can find potential problems during coding, and if properly used, it can improve code quality and robustness.

15. Configure Quick Document View

1. Set the document path

Open Settings, enter the Documentation path, click the "+" sign on the right, and select the location of the document to be accessed.

The common ones are JDK documents, Tomcat documents, etc.

2. Set shortcut keys

Enter Keymap, find Quick Documentation, and set convenient shortcut keys, such as Ctrl+Q.

3. View the document in the code

In the code, position the cursor on the class or method name, and press the shortcut key to quickly pop up the document viewing window.

4. Use dashes

In the code, enter "class name-" or "method name-", the relevant documents will be prompted, and you can directly press Enter to view them.

5. External Documentation

For external documentation pages, you can link them through the Documentation link, or you can quickly view them.

Make more use of various functions of IntelliJ IDEA, and don't rely too much on IDE, so as to find a balance between efficiency and flexibility.

write at the end

If you are interested in related articles, you can pay attention to the official account "Architecture Hall", and will continue to update AIGC, java basic interview questions, netty, spring boot, spring cloud and other series of articles, and a series of dry goods will be delivered at any time!

Guess you like

Origin blog.csdn.net/jinxinxin1314/article/details/132574423