Top 10 Intellij IDEA Shortcuts

There are a lot of keyboard shortcuts in Intellij IDEA to put it down, and there are some interesting discussions on stackoverflow . Everyone has their favorites, and it's hard to come up with an ideal list. I have also sorted out Intellij 's shortcut keys before. This time, according to the frequency of my daily development, I will briefly classify and list my top ten favorite shortcuts -God -keys .

1 Smart Tips

Intellij bears the brunt of course, Intelligence! Basic code prompts use Ctrl+Space , and more intelligently prompt Ctrl+Shift+Space by type information , but because Intellij always prompts automatically as we type, we often do not manually type these two shortcuts key (unless the tooltip disappears ). Use F2/Shift+F2 to move to the wrong code, Alt+Enter quick fix (i.e. Quick Fix function in Eclipse ). When the intelligent prompt automatically completes the method name for us, we usually have to fill in the back brackets and semicolons at the end of the line by ourselves. It will be troublesome when the brackets are nested many layers, then we just need to press Ctrl+Shift+Enter to Autocomplete characters at the end. And not just parentheses, for example , {} curly braces can be automatically added after typing if/for .

Last but not least, Intellij can intelligently sense the configuration files and classes of mainstream frameworks such as Spring and Hibernate, and act statically. Under the seemingly "static " appearance, Intellij can intelligently scan and understand how your project is constructed and configured.

2 Refactoring

Intellij refactoring is another feature that completely explodes Eclipse, and its intelligence is astounding. For example, when extracting variables, it automatically checks that all matches are extracted into one variable at the same time. Especially after reading "Refactoring - Improving Existing Code Design", the cooperation of Intellij is simply addicting! It is also the powerful intelligence and refactoring functions that make TDD development under Intellij very smooth.

Cut to the topic, let's talk about an invincible refactoring function summary shortcut Ctrl+Shift+Alt+T , called Refactor This. The method is a bit complicated, but it also conforms to the style of Intellij. Many shortcut keys have to be done with both hands, unlike many of the most useful shortcut keys in Eclipse, which can be done with one hand (I don’t know if it is a major advantage of Eclipse ), But if you have used Emacs, you will feel that it is nothing (non- Emacs black ). In addition, there are also some of the most commonly used refactoring techniques, because they are so commonly used, if they are selected in the Refactor This menu every time, the efficiency is somewhat inefficient. For example , Shift+F6 is to change the name directly, and Ctrl+Alt+V is to extract the variable.

3 Code Generation

This is similar to Eclipse, although it is not unique, but because of the extremely high frequency of daily use, it is still listed at the top of the list. Commonly used are fori/sout/psvm+Tab to generate boilerplate boilerplate code such as loop, System.out, main method, etc. You can view all templates with Ctrl+J . In the "Auxiliary " section, we will talk about Alt+Insert . Click in the editing window to generate constructors, toString, getter/setter, override parent class methods, etc. These two tricks are so common that a bunch of main, System.out, and getters/setters are generated almost every day.

In addition, Postfix Completion has been added to Intellij IDEA 13, which is more flexible and powerful than template generation. For example to type for(User user : users) just type user .for+Tab . For another example, to enter Date birthday = user.getBirthday(); just enter user.getBirthday() .var+Tab .

4 Edit

One of the great keys that I have to say in editing is Ctrl+W and reverse Ctrl+Shift+W that can automatically select the code according to the grammar . In addition, Ctrl+Left/Right moves the cursor to the word before/after, Ctrl+[/] moves to the code block before/after, these Vim-like cursor movements are also a highlight. The above Ctrl+Left/Right/[] plus Shift can select the code within the jump range. Alt+Forward/Backward moves to forward /backward methods. There are also some very common ones like Ctrl+Y to delete lines, Ctrl+D to copy lines, and Ctrl+</> to fold code.

To expand the cursor movement, in addition to the functions provided by Intellij itself, we can also install ideaVim or emacsIDEAs to enjoy the fast movement of Vim and the AceJump function of Emacs (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 bookmarks ), and then jump through Ctrl+Num . This avoids the trouble of jumping back and forth between using the previous /next editing position Ctrl+Left/Right multiple times , and this shortcut key conflicts with Windows hotkeys by default (the default is more Alt, which conflicts with Windows changing the display direction of the display, accidentally The display will become inverted and obvious, ah ).

5 Find Open

Similar to Eclipse, Intellij's Ctrl+N/Ctrl+Shift+N can open classes or resources, but Intellij is more intelligent, any characters we enter will be regarded as fuzzy matches, saving the trouble of typing * in Eclipse. The latest version of IDEA also added the Search Everywhere feature, just press Shift+Shift to search for anything in a pop-up box, including classes, resources, configuration items, methods, and more.

For the inheritance relationship of a class, you can use Ctrl+H to open the class hierarchy window, and to jump on the inheritance hierarchy, use Ctrl+B/Ctrl+Alt+B to correspond to the parent class or parent method definition and subclass or submethod implementation respectively, and view the current class. All methods use Ctrl+F12 .

To find the use of a class or method is also easy, Alt+F7 . To find the occurrence position of the text, use Ctrl+F/Ctrl+Shift+F to search in the current window or the whole project, and then cooperate with F3/Shift+F3 to move forward and backward to the next matching place.

Another proof that Intellij is more intelligent is that in any menu or display window, you can directly enter the word you are looking for, and Intellij will automatically filter it for you.

6 Other auxiliary

The above magic keys and some auxiliary shortcut keys can let your hands get rid of the mouse for more than 90% of the time, and focus on the keyboard as if performing a piano performance. These humble but crucial final pieces of the puzzle are:

Ø Commands: Ctrl+Shift+A can find all Intellij commands, and there are shortcut keys behind each command. So it is not only a great god key, but also a tool for finding and learning shortcut keys.

Ø New: Alt+Insert can create a new class, method, etc. anything.

Ø Formatting 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-running and debugging. Ctrl+Tab switches tabs, Ctrl+E/Ctrl+Shift+E opens recently opened or edited files.

Ø Unit test: Ctrl+Alt+T to create a unit test case.

Ø Run: Alt+Shift+F10 to run the program, Shift+F9 to start debugging, Ctrl+F2 to stop.

Ø Debugging: F7/F8/F9 correspond to Step into, Step over, and Continue respectively.

In addition, there are some custom ones, such as horizontal split screen Ctrl+| , etc., and some magical little functions Ctrl+Shift+V to paste the ones copied a long time ago, Alt+Shift+Insert to enter the column mode to select by column.

7 Final list

The lineup of this list is too luxurious, and the last few are so useful, they are not showing weakness.

Ø   Top #10 Cut to and fro: Ctrl+Tab

Ø   Top #9 Choose what you want: Ctrl+W

Ø   Top #8 Code Generation: Template/Postfix +Tab

Ø   Top #7 Giving orders: Ctrl+Shift+A

Ø   Top #6 Nowhere to hide: Shift+Shift

Ø   Top #5 Autocomplete: Ctrl+Shift+Enter

Ø   Top #4 Create everything: Alt+Insert

It's too hard to give up, let's tie the top three!

Ø   Top #1 Smart Completion: Ctrl+Shift+Space

Ø   Top #1 Self-healing: Alt+Enter

Ø   Top #1 Refactor everything: Ctrl+Shift+Alt+T

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324751993&siteId=291194637