There are plenty of shortcuts in Intellij IDEA to love, and there are some interesting discussions on StackOverflow. Everyone has their favorites, and it’s hard to come up with an ideal list. I’ve sorted out the Intellij shortcuts before, so here are my top ten favorite shortcuts based on how often I use them in daily development.
1 Intelligent Tips
The first Intellij is of course Intelligence Intelligence! The basic code prompts with Ctrl+Space and, more intelligently, Ctrl+Shift+Space by type message, but because Intellij always prompts as we type, most of the time you don’t hit either of these shortcuts manually (unless the prompt disappears). Use F2/ Shift+F2 to move the offending code, Alt+Enter to quickly Fix it (the Quick Fix feature in Eclipse). When the intelligence prompts us to auto-complete the method name, we usually have to complete the trailing backparenthesis and semicolon ourselves. When the parentheses are nested in many layers, it can be troublesome. In this case, we can auto-complete the trailing character by pressing Ctrl+Shift+Enter. And it’s not just the parentheses. For example, the {} curly braces can be added automatically after you type if/for.
Finally, Intellij is intelligently aware of configuration files and classes in mainstream frameworks such as Spring and Hibernate, so that it can silently scan and understand how your project is constructed and configured without seeming “static.”
2 refactoring
Intellij refactoring is another feature that has blown Eclipse out of the water. It is surprisingly smart, such as extracting variables automatically checking for all matches to be extracted into a single variable. Especially after seeing “Refactoring – Improving existing Code Design”, with the cooperation of Intellij is absolutely fascinating! It is the powerful intelligence and refactoring functions that make TDD development under Intellij very smooth.
To get to the point, let’s start with an awesome refactoring feature called Ctrl+Shift+Alt+T. It’s a bit complicated, but in keeping with The Intellij style, many of the shortcuts are two-handed, unlike some of Eclipse’s most useful shortcuts, which can be done handsomely with one hand. If you’ve ever used Emacs, that’s ok. In addition, there are some of the most common refactoring techniques, which are so commonly used that it would be inefficient to check the Refactor This menu every time. For example, Shift+F6 directly changes the name, while Ctrl+Alt+V directly extracts the variable.
3 Code Generation
This is similar to Eclipse, which is not unique, but is high on the list because it is used so often. Boilerplate boilerplate code can be generated with fori/sout/ PSVM +Tab, System. Out, main method and other boilerplate code. Ctrl+J can view all templates. Alt+Insert will be covered later in the “Assist” section. You can click in the edit window to generate constructors, toStrings, getters/setters, override superclass methods, and so on. These two techniques are so common that you generate a bunch of main, system.out, and getters/setters almost every day.
In addition, Intellij IDEA 13 adds Postfix Completion, which is more flexible and powerful than template generation. For example, to enter for(User User: users), enter user.for+Tab. For example, Date birthday = user.getbirthday (); Just type user.getbirthday ().var+Tab.
4 the editor
One of the great keys to edit is Ctrl+W, which automatically selects code syntactically, and Ctrl+Shift+W, which works the other way around. In addition, Ctrl+Left/Right moves the cursor to the front/back word and Ctrl+[/] moves the cursor to the front/back code block. These ViM-like cursor movements are also highlights. Ctrl+Left/Right/[] + Shift selects code within the jump range. Alt+Forward/Backward move to the Forward/ back method. There are some very common ones like Ctrl+Y deleting lines, Ctrl+D copying lines, and Ctrl+ folding code.
To extend cursor movement a bit further, in addition to what Intellij already offers, you can also install ideaVim or emacsIDEAs to enjoy Vim’s fast movement and Emacs AceJump (cool!). . In addition, Intellij’s bookmarking function is also good. Use Ctrl+Shift+Num to define 1-10 bookmarks (delete bookmarks by pressing this set of shortcuts again), and then use Ctrl+Num to jump. This avoids the trouble of skipping back and forth by using Ctrl+Left/Right for the previous/next edit position many times, and by default, this shortcut key conflicts with Windows hotkey (by default, if WE add Alt, it conflicts with Windows when changing the display direction, accidentally, the display will become an inverted display, orz).
5 Search open
Like Eclipse, Intellij’s Ctrl+N/Ctrl+Shift+N can open classes or resources, but Intellij is smarter and any character we type is treated as a fuzzy match, saving Eclipse the trouble of typing *. The latest version of IDEA also adds the Search Everywhere feature, which allows you to Search for anything in a pop-up box, including classes, resources, configuration items, methods, and more, by pressing Shift+Shift.
Class inheritance relationship can be used Ctrl+H to open the class hierarchy window, jump on the inheritance level with Ctrl+B/Ctrl+Alt+B corresponding to the parent class or parent method definition and subclass or submethod implementation, view all methods of the current class with Ctrl+F12.
It’s also easy to find classes or methods to use, Alt+F7. To find where the text appears, press Ctrl+F/Ctrl+Shift+F to find it in the current window or in the entire project, and then move forward and backward with F3/Shift+F3 to the next match.
Another example of Intellij’s greater intelligence is that you can enter the word you are looking for in any menu or display window, and Intellij will automatically filter it for you.
6 Other Assistance
These keys, combined with a few auxiliary shortcuts, can keep your hands off the mouse more than 90% of the time, focusing on the keyboard as if performing a piano performance. The final pieces of the puzzle are small but crucial:
ø Command: Ctrl+Shift+A can find all Intellij commands, and each command is followed by its shortcut key. So it is not only a great key, but also a tool to find learning shortcuts.
ø New: Alt+Insert can create classes, methods, and anything else.
ø Format code: Format import list Ctrl+Alt+O, format code Ctrl+Alt+L.
ø Switch window: Alt+Num, commonly used 1- project structure, 3- search results, 4/5- run debugging. Ctrl+Tab Toggles tabs, Ctrl+E/Ctrl+Shift+E opens recently opened or edited files.
ø Unit test: Ctrl+Alt+T creates a unit test case.
ø Run: Alt+Shift+F10 run the program, Shift+F9 start debugging, Ctrl+F2 stop.
ø Debug: F7/F8/F9 correspond to Step into, Step over, Continue respectively.
In addition, some of my custom, such as horizontal split screen Ctrl + | etc., and some small magical function Ctrl + Shift + V to paste copy of long ago, Alt + Shift + Insert into the column model according to the selected columns.
7 Final List
This list is too luxurious, the last few are so useful, not to show weakness.
ø Top #10: Ctrl+Tab
ø Top #9 Select what you want: Ctrl+W
ø Top #8: Template/Postfix +Tab
Command: Ctrl+Shift+A
ø Top #6 Nowhere to hide: Shift+Shift
ø Top #5 Auto complete: Ctrl+Shift+Enter
ø Top #4 Create everything: Alt+Insert
It’s too hard to give up. Let’s tie the top three!
ø Top #1 Intelligent completion: Ctrl+Shift+Space
ø Top #1 Self-repair: Alt+Enter
ø Top #1 Refactor everything: Ctrl+Shift+Alt+T