IDEA Super practical use tips share (long)

preface

Good work is good work

He must sharpen his weapon first

Recently, I was invited by the department to give new recruits unified IDEA training. I found that although many new recruits use IDEA in daily development, they still do not use many useful skills. They only use some basic functions, which is quite a waste of IDEA, an excellent IDE. At the same time, after this sharing, I also learned some new use skills, so take this opportunity to share. I hope I can help some people.

IntelliJ IDEA 2018.2.2 (Ultimate Edition)

Overview of Knowledge:

  • Efficient configuration
  • Essential Shortcuts for Daily Use (★★)
    • To find the
    • Jump to switch
    • Coding related
    • Code Reading Related
    • Version management related
  • Related to coding efficiency (★★)
    • File code template
    • Live code templates
    • other
  • Code debugging source read related (★★★)
    • View mode
    • Code debugging
    • .
  • The plug-in side
    • Plug-in installation and use
    • The plugin is recommended
  • reference

2019-08-09 UPDATE

[Plug-in recommendation] Added picture description, added plug-in content. Reading is friendlier.


Efficient configuration

1. The code prompt is case insensitive

Settings -> Editor -> General -> Code Completion

(For earlier versions, set the Case Sensitive Completion to None.)

2. Automatic package guide function and related optimization function

Settings -> Editor -> General -> Auto Import

3. CTRL + Scroll wheel to resize the window display

Settings -> Editor -> General -> Change font size (Zoom) with Ctrl+Mouse wheel

Once selected, you can adjust the font size of the editor window using CTRL+ scroll wheel

4. TAB displays multiple lines

This varies from person to person, some people like to just cancel all tabs and use shortcuts, but I have a big screen, so I like to show all tabs.

Window -> Editor Tabs -> Tabs Placement, uncheck the Show Tabs In Single Row option.

The effect is as follows:

5. Line numbers are displayed in the code editing area

Settings -> Editor -> General -> Appearance check Show Line Numbers

6…

Essential Shortcuts for Daily Use (★★)

To find the

shortcuts introduce
Ctrl + F Perform a text lookup in the current file
Ctrl + R Text replacement in the current file
Shift + Ctrl + F Do a text lookup in the project
Shift + Ctrl + R Text replacement in the project
Shift + Shift Quick search
Ctrl + N Look for the class
Ctrl + Shift + N Find files
Ctrl + Shift + Alt + N Look up symbol (looks up a method name)

Jump to switch

shortcuts introduce
Ctrl + E Recent documents
Ctrl + Tab Switch files
Ctrl + Alt + ←/→ Jump to the historical cursor
Alt + ←/→ Arrow key Switch the son TAB
Ctrl + G Go to the specified line number

Coding related

shortcuts introduce
Ctrl + W Rapid selected
(Shift + Ctrl) + Alt + J Quickly select the same text
Ctrl + C/Ctrl + X/Ctrl + D Quick copy or cut
Select Tab/Shift + Tab for multiple lines tab
Ctrl + Y Delete the entire line
Scroll to variable/method/class Quick access to the definition of a variable/method/class
Shift + Hit Tab Quickly close TAB
Ctrl + Z 、Ctrl + Shift + Z Regret medicine, withdraw/cancel withdraw
Ctrl + Shift + enter Automatic closure, code completion
Alt + enter IntelliJ IDEA provides a quick fix option based on the cursor’s location, and the prompt results vary depending on the cursor’s location
Alt + write/left Method quick jump
F2 Skip to the next highlighted error or warning location
Alt + Insert Code is generated automatically, such as generating object set/get methods, constructors, toString(), etc
Ctrl + Shift + L Formatting code
Shift + F6 Quickly change the method name, variable name, file name, class name, etc
Ctrl + F6 Quickly modify method signatures

Code Reading Related

shortcuts introduce
Ctrl + P Method parameter prompt display
Ctrl + Shift + i You can pop up another window in the current class
Alt + F7 You can list where variables are used
Cursor in subclass interface name, Ctrl + U Skip to the superclass interface
Alt + F1 + 1, esc
(Shift) + Ctrl + +/- Code block folding
Ctrl + Shift + ←/→ Move the window divider
Ctrl + (Alt) + B Jump method definition/implementation
Ctrl + H Class hierarchy
Ctrl + F12 Show Members displays Members quickly

Version management related

shortcuts introduce
Ctrl + D Show Diff
(Shift) + F7 (top) Next modification

For more shortcuts, see this article github.com/judasn/Inte…

For MAC OS shortcuts, see this article github.com/judasn/Inte…

Related to coding efficiency (★★)

File code template

Settings -> Editor -> File and Code Template

Here you can see all of IDEA’s built-in file code templates. When you select a file to generate, the specified code file will be generated according to the template.

In addition, you can set the file header here.

After setting, the effect is as follows

Live code templates

IDEA provides powerful real-time code template functionality, and has many built-in templates. For example, when you type sout or PSVM, it quickly automatically generates system.out.println (); Public static void main(String[] args) {}

These Templates can be seen in Settings -> Editor -> Live Templates. Users can become familiar with the relevant code template according to their own usage habits.

Custom code templates

IDEA also offers the ability to customize your own live code templates.

  1. Create your own template library
  2. Create custom code templates

MyGroup in the figure contains my own code template.

other

CRTL+ALT+T

Ctrl + Alt + T provides the code block wrap function – Surround With. You can quickly wrap the selected code block into the selected statement block.

Local Historical version

IDEA comes with local version management, so you can write code locally to become more secure and convenient.

Code debugging source read related (★★★)

View mode

IDEA provides two special view modes,

  1. Presentation Mode is used specifically for Code Review scenarios where you need to present Code
  2. Distraction Free Mode – Focus on code development

Code debugging

1. Conditional break point

IDEA can set breakpoints for specified conditions, increasing the efficiency of our debugging.

2. Mandatory return

IDEA can force you to return the desired method return value to the caller at the break point method stack. Very flexible!

3. Simulate exceptions

IDEA can force an exception to be thrown to the caller at the break point method stack. This is useful when debugging source code.

4. Evaluate Expression

IDEA can also dynamically change the value of variables in the current method stack when debugging code, which is convenient for debugging.

The plug-in side

Plug-in installation

File -> Setting -> Plugin

Plug-in installation, can be directly in the IDEA of the plug-in library real-time search installation. browse plugin repository

For user network is bad, can log in the official plug-in warehouse address: plugins.jetbrains.com/idea, download the package… from disk`

The plugin is recommended

I use the plug-in in daily development

Alibaba Java Coding Guidelines

Ali Java programming protocol plug-in

FindBugs

Code defect scanning

PMD

Code defect scanning

InnerBuilder

Builder mode is generated quickly

lombok plugin

Lombok plug-in

maven helper

Maven dependency Management helper, parsing Maven POM structures and analyzing conflicts

Rainbow brackets

Make parentheses in your code more identifying

String Manipulation

String related auxiliary simplified, with CTRL+W, ALT+J and other text to select the shortcut key to use

Translation

Translation plug-in, read the source code essential

GenerateAllSetter

Key Promoter X

Shortcut key prompts for your mouse operations

GenerateSerialVersionUID

Alt + Insert quickly generates SerialVersionUID

GsonFormat

RestfulToolkit

  1. Quickly jump to Restful Api (Use: Ctrl(Command) + \ or Ctrl + Alt + N)
  2. Presents a Resultful interface structure
  3. HTTP simple request tool

Material Theme UI

My personal theme is this.

MyBatis Log Plugin

Restore the SQL log output by Mybatis into a complete SQL statement, it looks more intuitive.

Free Mybatis

MyBatis free plug-in

reference

  1. Github.com/judasn/Inte…

(By the way, please refer to this extension and official documentation for more use of IDEA)