Are you all using IntelliJ idea? Maybe you need to take a look at this blog post.

Source: Internet
Author: User
Tags code tag
write in front

Used to be elipce, now into the pit IntelliJ idea, did not think AH. Deeply in love with it, strong to omnipotent;

"工欲善其事 its prerequisite", IntelliJ idea as a very useful tool, his magic is really a lot of, mastered the idea of the skills, development efficiency at least twice times more, and for some poor English learners are also very friendly, This article introduces in detail the common shortcut keys and some very useful gadgets, interested in the small partners to learn quickly;

Proficiency in these operations, encoding speed and quality must be able to get a qualitative leap;

One, view view ctrl+f12 View File,method structure diagram, class inheritance organization diagram

( do not know the method structure, Ctrl+f12, methods, parameters, return values, clearly displayed .

ctrl+shift+alt+u View maven dependencies, class diagram

When using MAVEN to do projects, the dependencies are often very much, only need to be ctrl+shift+alt+u in the configuration dependent files, all dependencies are presented in a topological diagram, and all relationships and locations can be found;

such as (sorry, the project relies too much, the specific dependence needs to enlarge)

Class diagram: When we read the source code, want to know the relationship between the various classes how to do, Ctrl+shift+alt+u, all the dependencies are shown in a topological map, all the relationship and location can be found, taking ArrayList as an example:

Ctrl+alt+h View method call hierarchy;

Second, positioning 1. Jumps between Projects

Ctrl+alt+[jump to the next item

Ctrl+alt+] Jump to previous item

2. Jumps between files

Ctrl+e navigating to a recently viewed file

Ctrl+shift+e recently changed files

Shift+click can close files

3. The location of the jump

Ctrl+shift+backspace Jump Last Modified place

Ctrl+alt+b Jump to method implementation

Ctrl+shift+ left arrow Last browse place

ctrl+shift+ right arrow next Browse place

4. Other jumps

Ctrl+h Show class structure diagram (inheritance hierarchy of classes)
Ctrl+q displaying comment documents
Alt+1 quickly open or hide the engineering panel
Alt+left/right Switch Code View
F2 or SHIFT+F2 highlighting error or warning quick location
After the tab code tag is entered, press TAB to generate the code
CTRL+SHIFT+F7 highlight all the text, press ESC to highlight the disappear

5. Search

CTRL + N Quick Search class
Ctrl+shift+n Quick Search Files

Ctrl+alt+shift+n Fast Search function

Three contains the Include NON-PORJECCT items option, which indicates that all classes in the jar that are not in the current file are also searched;

Ctrl+shift+f Fast Search string

Alt+f1 find where the code is located

Alt+f3 to find the same text one by one and highlight

6. Cursor movement and selection

Ctrl+alt+shift+j Select all the corresponding targets

Alt+up/down fast positioning between methods

Ctrl+shift+up/down Move statement up/down

Ctrl+up/down cursor to the first or last line

Ctrl+b/ctrl+click quickly open the class or method at the cursor (jump to definition)

Third, Alt+enter

Although only one combination button is used, it has a very large function.

1. Provide code hints

Code error as long as Alt+enter, he has provided us with a good solution;

2. Automatically create functions

Just write the function name, alt+enter it, it will help us to create a good function automatically;

3.list Replace

Write a list with a for traversal; Alt+enter, he tells you there's a better way to refactor:

Enter it to help you reconstruct;

4. Implementing the Interface

When we need to implement the interface, we just need to alt+enter on the name of the interface to do it.

5. Spelling words

Programmers are a lot of English is not good, alt+enter is simply their gospel;

When we are not sure if a word is spelled correctly, alt+enter it.

After the carriage return, it can list similar words,

We just need to find the right one OK, is not very useful.

6. Guide Package

When you need to use a package, you just need to move the cursor to the name you want to guide the package, Alt+enter import completed;

Four, Live Templates (template)

This is the definition of a large number of templates, only with a small number of letters to hit the hint, you can use the template to generate a lot of code;

We can also be used here to define common code as a template, such as Main method, for loop, etc., convenient and quick;

For example, public static final int can be defined as shown:

Not customizable Click to view: Tutorial To create a template

Wu, Postfix

When we write code, we write code that prompts us with dots, for example, 100. After hitting enter will generate a for loop, the use is Postfix, this is a faster than the live Templates helper, of course, it is also non-editable, which defines a large number of common functions and templates, skilled use can improve our many coding efficiency;

For example:

After carriage return the results are as follows

1  New ArrayList (); 2          for (int0; i < strings.size (); i++) {3             4         }

Vi. Reconstruction

Shift+f6 Renaming

All files, class names, function names, property names can be renamed,

It is worth to like, as long as you use Shift+f6 Rename, all use of the name of the place will follow change;

Refactoring of functions

Ctrl+f6 refactoring function

When you need to refactor the method, whether it is to increase the parameters, modify the return value, or change the function implementation, only need to CTRL+F6, you can use all of this function to refactor together, the interface is as follows

Seven, extraction

1. Extracting Variables

Similar to the picture in this way, many places have used the "aaaaaa" this string, it is obvious that we have "aaaaaa" extracted will be better;

Ctrl+alt+v to it.

We choose to extract one or extract all according to our own needs;

ctrl+alt+c extracting static variables ctrl+alt+f extracting member variables

Similar to using methods and extracting variables

Ctrl+alt+p Extracting method parameters Ctrl+alt+m Extraction Method

When a method length is too long, only need to separate the code into multiple modules, select each module as long as the ctrl+alt+m can be extracted as a new method, we only need to reference it;

A few other tips:

1. Every time the code is ctrl+alt+l, the code is beautiful and conforms to the specification;

IntelliJ Idea's function is really strong to burst, this is just a summary of a very small part, welcome everyone in the comment area to add;

Related articles:

IntelliJ idea 2018 Activates the idea Code specification plugin

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.