preface

Good work is good work

First sharpen your tools

Recently, I was invited by the department to train IDEA for new employees. I found that although many new employees use IDEA in daily development, they still do not use many useful skills, but 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 skills, so take this opportunity to share it together. I hope I can help some people.

IntelliJ IDEA 2018.2.2 (Ultimate Edition)

Efficient configuration

1. Code prompts are case insensitive

Settings -> Editor -> General -> Code Completion
Copy the code

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

2. Automatic package guide function and related optimization function

Settings -> Editor -> General -> Auto Import
Copy the code

3. CTRL + slide the scroll wheel to adjust the display size of the window

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

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

4. TAB displays multiple lines

This varies from person to person, some people like to just cancel all the tabs and use the shortcut keys, but I have a big screen, so I like to display all the 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
Copy the code

6…

Essential Shortcut keys for Daily Use (★★)

To find the

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

Jump to switch

shortcuts introduce
Ctrl + E Recent documents
Ctrl + Tab Switch files
Ctrl  + Alt + ←/→ Jump to the location of the historical cursor
Alt + ←/→ Arrow key Switch the son TAB
Ctrl + G Go to (jump to specify 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 Copy or cut quickly
Select Tab/Shift + Tab for multiple lines tab
Ctrl + Y Delete the entire line
Scroll to variable/method/class Quickly get to the definition of a variable/method/class
Shift + Tab Close TAB quickly
Ctrl + Z 、Ctrl + Shift + Z Rescind/cancel rescind
Ctrl + Shift + enter Automatic closure, automatic code completion
Alt + enter IntelliJ IDEA provides a quick fix option based on the problem of the cursor position. The prompt result varies with the cursor position
Alt + write/left Method Fast jump
F2 Jump to the next highlighted error or warning location
Alt + Insert Automatic code generation, such as generating object set/get methods, constructors, toString(), etc
Ctrl + Shift + L Formatting code
Shift + F6 Quickly modify method names, variable names, file names, class names, etc
Ctrl + F6 Modify method signatures quickly

Code reading correlation

shortcuts introduce
Ctrl + P Method parameter prompt is displayed
Ctrl + Shift + i You can pop up another window in the current class
Alt + F7 You can list where variables are used
Cursor on subclass interface name, Ctrl + U Jump 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 Class Members are displayed quickly

Versioning related

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

See this article for more shortcuts at github.com/judasn/Inte…

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

Coding efficiency correlation (★★)

File code template

Settings -> Editor -> File and Code Template 
Copy the code

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

In addition, you can set the file header here.

Once set, the effect is as follows

Real-time code template

IDEA provides powerful real-time code templates, and many templates are built-in natively. For example, when you type sout or PSVM, system.out.println () will be generated quickly and automatically. Public static void main(String[] args) {}

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

Custom code templates

IDEA also provides the ability to customize your own real-time code templates.

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

The MyGroup in the figure holds the code template I defined myself.

other

CRTL+ALT+T

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

Local History Version

IDEA comes with local version management, which makes it easier to write code locally.

(★★★)

View mode

IDEA offers two special view modes,

  1. Presentation Mode – For Code Review scenarios where Code needs to be shown
  2. Distraction Free Mode — Zen Mode, which focuses on code development

Code debugging

1. Conditional breakpoints

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

2. Forcibly return

IDEA can force the method return value you want to the caller at the interrupt point on the method stack. Very flexible!

3. Simulate exceptions

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

4. Evaluate Expression

IDEA can also dynamically modify the values 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 
Copy the code

Plug-in installation, you can directly search for the installation in real time in the PLUGIN library of IDEA. browse plugin repository

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

The plugin is recommended

I use plug-ins in daily development

Alibaba Java Coding Guidelines

Ali Java programming protocol plug-in

FindBugs

Code defect scanning

PMD

Code defect scanning

InnerBuilder

Builder mode quick generation

lombok plugin

Lombok plug-in

maven helper

Maven relies on management assistants to parse Maven POM structures and analyze conflicts.

Rainbow brackets

Make parentheses in your code more identifying

String Manipulation

String related auxiliary simplification, with CTRL+W, ALT+J and other text selection shortcut keys to use

Translation

Translation plug-in, read the source code necessary

GenerateAllSetter

Key Promoter X

Shortcuts for your mouse operations

GenerateSerialVersionUID

Alt + Insert quickly generates SerialVersionUID

GsonFormat

RestfulToolkit

  1. Quick jump to Restful Api (use: Ctrl(Command) + \ or Ctrl + Alt + N)
  2. This section describes the Resultful interface structure
  3. HTTP simple request tool

Material Theme UI

My own theme is this.

MyBatis Log Plugin

Mybatis output SQL log restore into a complete SQL statement, looks more intuitive.

From: juejin. Cn/post / 6844903906665824270