Improving development efficiency by ton: IntelliJ shortcuts simplified subset and thinking mode

Time:2020-11-4

Online simplified cheatsheet reference table:intellij.linesh.tw
GitHub project:intellij-mac-frequent-keymap

Improving development efficiency by ton: IntelliJ shortcuts simplified subset and thinking mode

IntelliJ’s shortcut keys are numerous and complexOfficially recommended keymapTo a lot of personal summary on the Internet, the information can be said to be vast. contrary,How to quickly find the most frequently used and most efficient shortcut keys among the numerous shortcut keysIt becomes a difficult problem. This cheatsheet is just to solve this problem that may be encountered in the learning process of IntelliJ shortcut keys.

In the past year, I read a lot of information about Intellij shortcuts and using ideas. Whether it’s official keymap or personal blog, combined with my usual work and personal experience, I try to sort out and summarize the best part of it. At the same time, I sum up, think about and improve efficiency related thinking patterns and ideas through this subset. Share it out, hoping to provide useful help to the students in Xuehai.

Target readers and groups

  • Students who want to get started with the IntelliJ shortcut key quickly. Many other materials with no emphasis should be read. It is the best and most common shortcut to learn the best way to save time and efficiency.

  • Students who want to constantly compare and simplify your shortcut key set. After all, how many hot keys, remember the most useful

  • for reference。 This is the main purpose, save a bookmark or a web address, when necessary, as long as there is a network, cross platform can be checked at any time

  • Try to improve the level of thinking, from the perspective of ideas and thinking mode to view programming and tools of students

Concept and mode of thinking

IDE and computer, as tools, are always the AIDS to accomplish specific tasks efficiently. Therefore, what we call efficiency has a context: to complete the work, in this process, the role of tools is to assist work. So, the so-called efficiency is to ask, how to focus on the work itself and finish the work more efficiently? Behind a series of landing shortcut keys, what is the concept and thinking mode of the working system around shortcut keys to improve work efficiency? My answer is:

  • Higher level of abstraction

  • Declarative use

Higher level of abstraction

A higher level of abstraction refers to thinking about programming from the level of code and the characteristics of the language itself, rather than just text or strings. Thinking should be changed from “cutting and copying these five lines of code into a new method” and other low-level activities that regard code as meaningless characters to thinking based on the elements and characteristics as the core of the language, such as class, variable, method, rename, refactoring, if else, loop, recyclable elements, etc.

In this regard, IDE providesLive TemplateRefactoring, partial backward declarations, etc., are the products of this idea, allowing you to think about code at a higher level (language features, Java related refactorings) and mask the details up as much as possible.

Declarative use

Declarative use refers to the direct use of elements (classes, fields, methods, etc.) that you need to complete the work, and let the IDE automatically complete the missing declaration or definition for you. This idea also runs through the entire toolset, using tools in more semantic (higher-order) operations.

In this regard, IDE providesPostfix auto completionAuto completionAll of them are the products of this thought. You don’t need to pay attention to the context of the operation. Ide will complete it for you. You need to focus on the work and the operation itself.

How can this cheatsheet be used?

Records like this kind of cheatsheet may become obsolete with time or version changes, and excessive customization may increase tracking and maintenance costs. In order to reduce the maintenance cost as much as possible and keep the validity of the cheatsheet as long as possible, the selection of the following shortcut keys follows the following principles:

  • Lists only the shortcut keys for the Mac version

  • Use the keymap of Mac OSX 10.5 + as the benchmark

  • In principle, only delete the keymap as the benchmark, that is, unnecessary shortcut keys may be deleted, but the default enabled shortcut keys will not be changed for non special reasons

  • For a few shortcut keys that need to be changed, I will use an asterisk to indicate the reason

Shortcut key reduction subset

This chapter is divided into seven parts: productivity killer, language elements generation, editing, navigation, reconstruction, search, runtime. The version control section was not entered because I prefer to use the command line commit rather than the IDE’s built-in VCs support. opinions differ. The last column is the name of the operation in idea, which can be found by retrieving the corresponding action / shortcut in keymap.

Productivity

Operation Mac OSX 10.5+ Comments Description
Template completion ⌘+J Insert a template that conforms to certain structural features. See below for details Insert live template
Command query ⇧+⌘+S Querying an operation or shortcut key in the form of name is the perfect embodiment of declarative programming Find actions
Intention prediction and intelligent help ⌥+Enter Simple refactoring, removing dead code, structure adjustment, automatic package guiding, etc Show intention actions

Live template

After typing the keyword of template completion below, you can directly trigger template completion through tab or enter. The template variable that you need to fill in is $1 / $2.

Operation Mac OSX 10.5+ Keyword Expands to Comments
Void judgment ifn if ($1 == null) {} The back declaration also has the same function, the reader may choose the convenient use
Judgment is not empty inn if ($1 != null) {}
Create index loop fori for (int $1 = 0; $1 < $2; $1++) {}
Add todo todo // TODO: $1 The usage of non declarative
Add fixme fixme // FIXME: 7/19/16 $1 ditto
Determination of type relation inst if ($1 instanceof $2) {}
System.out sout System.out.println($1); Must start with the black skills, debugging log is very useful

Postfix completion

Backward statementJetBrains is a new function of IDE, which aims to reduce the cursor moving back and forth frequently, improve the development efficiency, and form such programming thinking: first use elements, then consider variable declaration or structure completion. Its main function is to provide possible behavior suggestions according to the attributes of the current element, such as using if else structure to surround, judge (not) null, format, and type conversion. Therefore, the choices provided by a backward declaration vary depending on the elements (mainly variables).

All elements have some choice of backward declaration, only choose what I think is commonly used:

Operation Postfix Completion Keyword Expands To Comments
Variable declaration element.var Type $name = element; Essential skills, model of declarative use
Convert to class field element.field private $Type element; Just found out
Prints the current variable to the output stream element.sout System.out.println(element);
Returns the current value element.return return element;
Type conversion element.cast (($Type) element)

Then, for certain element types, some backward declarations also have very practical options, such as null detection of string, if else of Boolean value, loop of list, etc

ElementType Operation Postfix Completion Keyword Expands To Comments
character string Void judgment string.null if (string == null) {}
Judgment is not empty string.notnull if (string != null) {}
integer branch int.switch switch (int) {}
Boolean value If true boolean.if if (boolean) {}
If false boolean.else if (!boolean) {}
Antonymy boolean.not !boolean
list Cyclic elements lists.for for (Type element : lists) {} Very common
Loop with index lists.fori for (int i = 0; i < lists.size(); i++) {}

Editing

Operation Mac OSX 10.5+ Comments Description
Basic code completion ^+Space Generally, this complement is used. It is often used in variable naming and method completion Code/Completion/Basic
Intelligent completion ^+⇧+Space Is it necessary to remember the two shortcut keys? It can be unified into one Code/Completion/SmartType
Sentence completion ⇧+⌘+Enter Complete the current statement directly, which is very useful when there are too many parentheses Complete Current Statement
Start a line from the top ⌥+⌘+Enter Start New Line Before Current
Start a line from the bottom ⇧+Enter Start New Line
Move up / down one line ⇧+⌥+↑/↓ Move one line up and down. It is generally used for elements that appear in a single line, otherwise the relationship between elements will be destroyed Move Line Up/Down
Move one block up / down ⇧+⌘+↑/↓ Move Statement Up/Down
Select a code block ⌥+↑ Commonly used Extend Selection
Unselect code block ⌥+↓ Shrink Selection
Repeat current line ⌘+D Duplicate Current Line or Block
Copies and does not delete the current row ⌘+C Edit/Copy
Cuts the current row and copies it to the pasteboard ⌘+X Edit/Cut
Close current label ⌘+W Same as usual editor shortcut key Edit Tabs/Close
Comment current line ⌘+/ Notes Comment with Line Comment
Optimize import ^+⌥+O It’s no use Optimize Imports
formatting code ⌥+⌘+L It’s no use Reformat Code

Language elements / features

Operation Mac OSX 10.5+ Comments Description
Test and method generation ^+Enter/ ⌘+N It is very commonly used to create test methods, construct methods, override interface methods, and override base class methods Code/Generate
Create classes, files, directories ⌘+N Commonly used Code/Generate
Create override method ^+O Useful Override Methods
Create interface method implementation ^+I Useful Implement Methods

Navigation

Operation Mac OSX 10.5+ Comments Description
Go to declaration of method / field ⌘+B Debugging and code are very common Navigation/Declaration
Go to the implementation point of the method / field ⌥+⌘+B Same as above, commonly used Navigation/Implementation(s)
Go to the class definition of the method / field type ⇧+⌘+B/ ⇧+^+B It is often replaced by the next two shortcut keys Navigation/Type Declaration
Jump between current class and unit test ⇧+⌘+T Very convenient Navigate/Test
Jump to the base class of the current class ⌘+U Matching food, better effect Super Method
Class inheritance system ^+H Type Hierarchy
Method inheritance hierarchy ⇧+⌘+H Method Hierarchy
Current method call chain ^+⌥+H Call Hierarchy
List of methods of this class and all base classes ⌘+F12 File Structure
Quick preview of class / method / field definition ⌥+Space/ ⌘+Y In general, you can see the method / field parameters, return value, and the implementation of the first few lines. Fast information is enough Quick Definition
Method document quick Preview ^+J Looking at documents, I don’t use them very often Quick Documentation
Quick preview of method parameters ⌘+P Commonly used Parameter Info
Previous label ⇧+⌘+[ Navigation is commonly used, but whether it can be replaced by other ways, such as declarative use of classes to find ⌘ + O, etc. Still exploring Select Previous Tab
Next tab ⇧+⌘+] Select Next Tab
One step up ⌥+⌘+←/ ⌘+[ It is very useful to call code and methodology Navigate/Back
Down one level ⌥+⌘+→/ ⌘+] Navigate/Forward
Go to the next error or warning F2 When the code is red, the shortcut key is often used for quick positioning and quick repair with the universal shortcut key ⌥ + enter Next Highlighted Error
Prompt error message ⌘+F1 Not commonly used Error Description
Intention prediction and intelligent help ⌥+Enter Simple refactoring, removing dead code, structure adjustment, automatic package guiding, etc Show intention actions
Project view ⌘+1 Sometimes navigation project structure is often used, I wonder if there is an alternative Other/Project
Search / find view ⌘+3 With the exception of these, no other view is commonly used Other/Find
Run view ⌘+4 Sometimes switch test view Other/Run
Debug view ⌘+5 Other/Debug
VCs view ⌘+9 Other/VCS
Terminal view * ⌘+0 I changed it. First, it was consistent with the shortcut keys of various views. In addition, the original ⌘ + F12 was a little difficult to press Other/Terminal
Hide all tool views ⇧+⌘+F12 Open the project and terminal view at the same time, one key back to the programming page Hide All Tool Windows
Jump to line ⌘+L It belongs to the detail type of work. If you can use less, you can think more about alternatives Navigate/Line…

Refactor

Operation Mac OSX 10.5+ Comments Description
Copy class / directory, etc F5 Refactor/Copy
Mobile class / directory, etc F6 Refactor/Move
Element (class / method / variable /…) )Rename ⇧+F6 One of the most commonly used refactoring shortcuts Refactor/Rename
Class / method signature modification ⌘+F6 Refactor/Change Signature
Field (class level) extraction ⌥+⌘+F Extract/Field
Constant (class level) extraction ⌥+⌘+C Extract/Constant
Variable (method level) extraction ⌥+⌘+V Extract/Variable
Parameter (method level) extraction ⌥+⌘+P Extract/Parameter
Method extraction ⌥+⌘+M One of the most common refactoring shortcuts Extract/Method
Method Inlining ⌥+⌘+N Refactor/Inline

Searching

Operation Mac OSX 10.5+ Comments Description
search ⌘+F Common shortcut keys Find/Find
replace ⌘+R Where regularity works Find/Replace
Find reference point ⌥+F7 It is often used in refactoring or debugging Find/Find usages
Find class ⌘+O Declarative programming, the use of high-frequency shortcut keys Navigate/Class
Find files ⇧+⌘+O Same as above, very frequently used Navigate/File
Find symbol ⌥+⌘+O Basically not. I don’t know the difference between them Navigate/Symbol
Full project text search ⇧+⌘+F It’s useful to search for reference points and text, and to correct bugs Find/Find in path
Find next ⌘+G Find/Find Next
Find previous ⇧+⌘+G Find/Find Previous

Runtime

Operation Mac OSX 10.5+ Comments Description
compile ⌘+F9 When debugging a bug, you may forget to compile the latest code Make Project
Run (last test) ^+R Very useful, and sometimes may save you switching between test code and source files Run/Run
debugging ^+D Run/Debug
Break point / cancel breakpoint ⌘+F8 Toggle Breakpoints
View all breakpoints ⇧+⌘+F8 View Breakpoints
Jump in F7 Run/Step Into
Jump out ⇧+F8 Run/Step Out
Smart jump in (when the current row has multiple calls) ⇧+F7
Skip (next step) F8 Run/Step Over
Evaluate the expression ⌥+F8 Evaluate Expression
Stop debugging ⌘+F2 Run/Stop

Recommended Today

Computer basic summary of 2021 autumn recruitment interview – operating system

A series of articles: 2021 autumn recruitment interview computer foundation summary – algorithm, data structure, design pattern, Linux Computer foundation summary of 2021 autumn recruitment interview – Java foundation, JVM, spring framework Computer foundation summary of 2021 autumn recruitment interview database, redis Computer basic summary of 2021 autumn recruitment interview – operating system Computer foundation […]