There are many shortcut keys in Intellij IDEA that make people love, and there are also some interesting discussions on stackoverflow. Everyone has their own favorites, and it is really difficult to get an ideal list. I have also sorted out Intellij's shortcut keys before. This time, I will briefly classify the top ten favorite shortcut keys - God-keys according to my daily development frequency.
1 Smart Tips
Intellij is of course the first thing to do with Intelligence! Basic code prompts Ctrl+Space, and Ctrl+Shift+Space is more intelligently prompted by type information, but because Intellij always automatically prompts as we tap, we often don’t manually tap these two shortcut keys (unless the prompt box disappears). Use F2/Shift+F2 to move to the wrong code, Alt+Enter quickly fix (i.e. Quick Fix function in Eclipse). When the smart prompt automatically completes the method name, we usually have to fill in the end of the line inverted brackets and semicolons. It will be troublesome when the brackets are nested in many layers. At this time, we just need to type Ctrl+Shift+Enter to automatically complete the end of the characters. And it is not just brackets, for example, you can also automatically add {} curly brackets when you type if/for.
Finally, I want to say that Intellij can intelligently sense configuration files and classes of mainstream frameworks such as Spring and Hibernate, and use static braking to intelligently scan and understand how your project is constructed and configured under a seemingly "static" appearance.
2 Reconstruction
Intellij refactoring is another perfect Eclipse function, its intelligence is astonishing, such as automatically checking all matches when extracting variables and extracting them into one variable at the same time. Especially after watching "Refactoring - Improving Existing Code Design", it is simply exciting to have Intellij's cooperation! It is also the powerful intelligence and reconstruction functions that make TDD development under Intellij very smooth.
Getting to the point, let’s talk about an invincible refactoring function summary shortcut key Ctrl+Shift+Alt+T, called Refactor This. The pressing method is a bit complicated, but it also conforms to the style of Intellij. Many shortcut keys need to be completed with both hands, unlike Eclipse. Many of the most useful shortcut keys can be completed with one hand (I don’t know if it is considered a major advantage of Eclipse). However, if you have used Emacs, you will feel that it is nothing (not Emacs black). In addition, there are some of the most commonly used reconstruction techniques, because they are too often used, and if you choose them in the Refactor This menu every time, it will be a bit inefficient. For example, Shift+F6 is directly renamed, while Ctrl+Alt+V is extracting variables.
3 Code generation
This point is similar to Eclipse. Although it is not unique, it is still listed on the top of the list because it is very frequent in daily use. Commonly used include fori/sout/psvm+Tab to generate boilerplate boilerplate template codes such as loops, System.out, main methods, etc., and use Ctrl+J to view all templates. The following "Auxiliary" section will talk about Alt+Insert. Clicking in the edit window can generate constructor, toString, getter/setter, rewriting parent class method, etc. These two techniques are so common that you have to generate a bunch of main, System.out and getter/setter almost every day.
In addition, Intellij IDEA 13 has added a postfix completion function (Postfix Completion), which is more flexible and powerful than template generation. For example, to enter for(User user: users) just enter user.for+Tab. For example, to enter Date birthday = user.getBirthday(); just enter user.getBirthday().var+Tab.
4 Edit
One of the keys that I have to mention in the edit is that the code can be automatically selected by syntax and the reverse Ctrl+Shift+W. In addition, Ctrl+Left/Right moves the cursor to the front/back words, and Ctrl+[/] moves to the front/back code block. These Vim-style cursor movements are also a highlight. If you add Ctrl+Left/Right/[] above, you can select the code within the jump range. Alt+Forward/Backward moves to the front/back method. There are also some very ordinary ones like Ctrl+Y delete lines, Ctrl+D copy lines, and Ctrl+</> collapse codes.
Regarding cursor movement, in addition to the functions already provided by Intellij itself, we can also install ideaVim or emacsIDEAs to enjoy Vim's fast movement and Emacs' AceJump function (super cool!). In addition, Intellij's bookmark function is also good. Use Ctrl+Shift+Num to define 1-10 bookmarks (press this set of shortcut keys again to delete the bookmark), and then jump through Ctrl+Num. This avoids the trouble of jumping back and forth between Ctrl+Left/Right in the previous/next editing position, and this shortcut key conflicts with Windows hotkey by default (there is more Alt by default, which conflicts with Windows changing the display direction of the display, and the monitor becomes explicit if you accidentally, ah).
5 Find Open
Similar to Eclipse, Intellij's Ctrl+N/Ctrl+Shift+N can open classes or resources, but Intellij is smarter. Any characters we enter will be regarded as fuzzy matching, saving the trouble of inputting * in Eclipse. The latest version of IDEA also adds the Search Everywhere function. Just press Shift+Shift to search for anything in a pop-up box, including classes, resources, configuration items, methods, etc.
The inheritance relationship of a class can be used to open the class hierarchy window with Ctrl+H. When jumping at the inheritance level, use Ctrl+B/Ctrl+Alt+B to correspond to the parent class or parent method definition and subclass or child method respectively. Use Ctrl+F12 to view all methods of the current class.
It is also very simple to find a class or method to use, Alt+F7. To find the location of the text, use Ctrl+F/Ctrl+Shift+F to search in the current window or in the entire project, and then move back and forth to the next matching place with F3/Shift+F3.
Another proof of Intellij's smarter nature is that you can directly enter the word you are looking for in any menu or display window, and Intellij will automatically filter it for you.
6 Other auxiliary
The above magic keys are paired with some auxiliary shortcut keys to get rid of your hands more than 90% of the time, and focus on the keyboard as if you are performing a piano performance. These inconspicuous but crucial last puzzle pieces are:
Ø Command: Ctrl+Shift+A can find all Intellij commands, and each command has its shortcut keys after it. So it is not only a great key, but also a tool for finding learning shortcut keys.
Ø New: Alt+Insert can create new classes, methods, etc.
Ø Format code: Format the import list Ctrl+Alt+O, format code Ctrl+Alt+L.
Ø Switch window: Alt+Num, commonly used are 1-project structure, 3-search results, 4/5-run debugging. Ctrl+Tab switches the tab page, Ctrl+E/Ctrl+Shift+E
Open recently opened or edited files.
Ø Unit Testing: Ctrl+Alt+T creates unit test cases.
Ø Run: Alt+Shift+F10 runs the program, Shift+F9 starts debugging, Ctrl+F2 stops.
Ø Debugging: F7/F8/F9 corresponds to Step into, Step over, and Continue respectively.
In addition, there are some that I customize, such as horizontal split screen Ctrl+|, and some magical small functions Ctrl+Shift+V, paste and copy a long time ago. Alt+Shift+Insert enters the column mode and selects it according to the column.
7 Final List
This list is too luxurious, and the last few are so useful and not showing any weakness.
Ø Top #10 Cut back and forth: Ctrl+Tab
Ø Top #9 Choose what you want: Ctrl+W
Ø Top #8 Code Generation: Template/Postfix +Tab
Ø Top #7 Issuing orders: Ctrl+Shift+A
Ø Top #6 Nowhere to hide: Shift+Shift
Ø Top #5 Automatic completion: Ctrl+Shift+Enter
Ø Top #4 Create Everything: Alt+Insert
It's too hard to give up, the top three are tied!
Ø Top #1 Intelligent Completion: Ctrl+Shift+Space
Ø Top #1 Self-healing: Alt+Enter
Ø Top #1 Refactor everything: Ctrl+Shift+Alt+T
Summarize
The above are the top ten shortcut keys for Intellij IDEA introduced to you by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to Wulin.com website!