JetBrains IDE basic shortcuts

Reprinted from: https://nextfe.com/jetbrains-ide-shortcuts/

A good craftsman very familiar with his tools. Software developers are no exception. Therefore, in the process of programming, it is worth understanding some of the keyboard shortcuts, click on the menu item to avoid because of rhythm and scattered attention, interference coding. This article will introduce the IntelliJ shortcut keys (Translator's Note: Most of the content is equally applicable to other JetBrains IDE, including common front-end development and Android development WebStorm commonly used Android Studio). Although IntelliJ almost all functions are shortcuts, but be an effective programmer does not need to know all the shortcuts. Instead, this article will introduce a small amount of shortcuts my colleagues and I use every day to master these shortcuts allow you to become a more skilled software developers.

I put a little keyboard shortcut set points for easy reading. The following IntelliJ shortcut keys based on the default Windows configuration, if you use a different program shortcuts, see the IDE Help (Help -> Keymap Reference) for the appropriate shortcuts. (Translator's Note: Since many developers use macOS operating system, notes the corresponding shortcut keys macOS program).

Navigation shortcuts

Ctrl + Tab (^ Tab) - switch tabs
to quickly switch between open files. Can be moved one by one to open the file in the list while holding down the Ctrl key is not released, it will switch to the appropriate file when released.

Ctrl + E (⌘ E) - View recent file
lists recently accessed files.

Ctrl + B (⌘ B) - Jump to declare / implemented
Press shortcut keys at a certain method will jump to the declaration of the method, for example, the corresponding interface. Instead, press Ctrl + Alt + B (⌘ ⌥ B) does not jump to the interface, but the jump to the implementation of the interface, which can often save a lot of time.

Double-click Shift (⇧⇧) - search for any content
quickly double-tap shift, quickly search the contents of any project, including the contents of any file, actions, including class.

Ctrl + N (⌘ O) - Find a class
if known need to find a class, then do not use any shortcuts search the contents of the above. After pressing this shortcut, start typing the name of the class. Do not have to enter the full class name, simply enter the front section, or enter only the class name in capital letters, you can also enter an asterisk (*) wildcard.

Ctrl + Shift + N (⌘ ⇧ O) - find files
when you need to find a text file or a configuration file, the shortcut keys easily.

Ctrl + Shift + T (⇧ ⌘ T) - Jump to the test
if you are addicted to test slightly, so this shortcut allows you to quickly jump between testing and implementation. When the Press shortcut keys at the test, it will jump to the appropriate implementation. On the contrary, in the implementation of the Press shortcut key, it will jump to the corresponding test. If the test does not exist, according to the test frame you choose, automatically creates a corresponding test class.

Ctrl + Alt + F7 (⌘ ⌥ F7) - display cases
display cases with all the current methods, classes, variables in the pop-up dialog box, so you can quickly jump.

Ctrl + F12 (⌘ F12) - a structural view of
a display attribute, list of methods, a convenient overview of the use of the current class.

Ctrl + G (⌘ L) - Jump to the line
A colleague asked you the code on line 45 is what to do, this handy shortcut keys so that you can quickly jump to the corresponding code.

F2 (F2) - Jump to an error / warning
IntelliJ when there is error or warning (top-right of editing a small area of the status icon), jumps to the next by pressing the F2 errors / warnings. This shortcut will help you keep the status icon evergreen. Thank Anton Arhipov proposal to join the shortcuts.

Editing shortcuts

In addition to navigation, we hope to speed when writing code. The following shortcuts will help us achieve this.

Ctrl + W (⌥ Up) - Extended selection area
This is my personal most frequently used shortcuts. You do not need to use the mouse to select the text, simply jump to an element in the code, then press the shortcut key. It intelligently selected extended regions, from the word to the sentence, the sentence blocks of code from the code block to a method, and so on. When you want to extraction method is particularly convenient. Ctrl + Shift + W (⌥ Down ) will narrow the selection area.

Ctrl + Space (^ Space) - basic code completion
after must master the shortcuts, press this shortcut, it will complement code. After completion in the pop-up menu, select completion item, press Enter or Tab to confirm. Typically, the same effect as press Enter or Tab, but when there are characters right of the cursor, only the insertion completion press Enter key, and will be used to complement press Tab Replaces right of the character. Therefore, use of Tab can be removed manually delete characters you no longer need the trouble.

Alt + Enter (⌥ Enter) - show intent
amendments introduced, run the test, and optimize the introduction, and so on. If your code has a problem, make the shortcut keys to repair. If your code is no problem, the shortcut keys that make your code better.

Ctrl + Shift + Enter (⌘ ⇧ Enter) - completion statement
on my experience, this is a shortcut key has been seriously underestimated. Less parentheses? Less semicolon end of the line? Whether the cursor is not the end of the line, press this shortcut can complement the necessary character.

Ctrl + D (⌘ D) - Copy the current line
based on my experience, there are still many people use the mouse to select the current line, copy, and paste. In contrast, Ctrl + D (⌘ D) can save a lot of time: you can add a new row after pressing, the contents of the current line and the same. If the currently selected multi-line, this shortcut will repeat the entire block of code.

Ctrl + Y (⌘ ⌫) - delete the current line
similar Ctrl + D (⌘ D), the shortcut keys can be deleted lines of code.

Ctrl + / (⌘ /) - comments on the current line
no matter what position the cursor in the current line, simply press the shortcut keys you can comment out the current line. Personally, I never use this shortcut commented code, but sometimes I'll use this shortcut to switch a piece of code is running. However, remember never to submit code commented out.

Reconstruction of shortcuts

One of the greatest strengths of IntelliJ is ample opportunity to reconstruct surplus. Despite the opportunity to refactor the code a lot, 90% of the practice, the reconstruction of shortcuts used is listed below me.

Ctrl + Alt + M (⌘ ⌥ M) - extraction method
selected piece of code (such as mentioned previously use Ctrl + W / ⌥ Up shortcut key), then press Ctrl + Alt + M (⌘ ⌥ M), can the code will be selected for the new extraction method or an anonymous function expression.

Shift + F6 (⇧ F6) - Rename
either method, variable, or a class, press Shift + F6 (⇧ F6) can replace the currently selected element in the one-time code all use cases. But be careful, the default configuration IntelliJ a bit radical, but also the replacement text use cases, which often is not to your meaning. Press twice Shift + F6 (⇧ F6) will provide the Rename option, so you can customize settings. I suggest to replace only the code, close the text alternatives.

Ctrl + Alt + V (⌘ ⌥ V) - extraction variables
Similarly, using Ctrl + W / ⌥ Up selected piece of code, then press Ctrl + Alt + V (⌘ ⌥ V), can create a new variable, variable often the correct type, name often is reasonable. When the expression passed to the method or class assignment to a variable often enhances readability, this time the shortcut is very convenient.

Epilogue

IntelliJ has over 100 shortcuts, but there is no need to fully grasp. On the trip to enhance efficiency in the use of IntelliJ, which my colleagues and most commonly used shortcuts should give you a big advantage.

An additional suggestion, install Key Promoter X plug-ins. When you use the mouse and menu items, this plugin will prompt the appropriate shortcut keys. Learning efficient use IntelliJ shortcut key, which is a helpful tool. I missed your favorite keyboard shortcuts? Please leave a message to tell me.

Guess you like

Origin www.cnblogs.com/wuyongqiang/p/11326541.html