Click on the above “ Zhu Xiaosi's blog ”, choice “ Set to star ”
The background to reply " book ", obtain
The background to reply “k8s”, Can claim k8s Information
Intellij IDEA The more you use it, the more powerful it is , It's always when we write code , Give us a little surprise from time to time . for
Intellij IDEA The love of , I decided to write a column or series about it , Put some good ones
Intellij IDEA Tips to share . This is the first article in this series , It mainly introduces some practical tips that you may not know .
We can use 【Presentation Mode】, take
IDEA Get the biggest , You can only focus on the code in one class , To carry on without interference
have access to
Alt+V Shortcut key , eject
View View , And then choose
Enter Presentation Mode. The effect is as follows ：
The advantage of this model is , Can make you more focused , Because you can only see the code for a specific class . Maybe the reader will ask , After entering this mode , I want to see what to do with other classes of code ？ This is the time , It's about to test your keyboard proficiency . You can use
CTRL+E Pop up recently used files . Or use
CTRL+SHIFT+N Location file .
How to exit this mode ？ It's simple , Use
ALT+V eject view View , And then choose
Exit Presentation Mode that will do . But I strongly advise you not to , Because you can be in
Enter Presentation Mode In mode
IDEA Do anything in it . Of course, the premise is , You are right about
IDEA Proficient enough .
If you use
JSON String time , Then one by one
\ To escape double quotes , It's really not right , It's annoying and easy to make mistakes . stay
IDEA have access to
Inject language Help us automatically escape double quotes .
First, focus on the double quotes , Use
alt+enter The shortcut key pops up
inject language View , And select
Inject language or reference.
After selection , Bear in mind , Press... Directly
enter Enter key , To pop up
inject language list . Choose... From the list
json Components .
After the choice . Mouse focus will be automatically positioned in double quotes , This time you use
alt+enter You can see that
Edit JSON Fragment And return , You can see the editor
JSON View of the file .
You can see
IDEA It does help us automatically escape double quotes . If you want to quit editing
JSON View of information , Just use
ctrl+F4 The shortcut key can .
Inject language There are so many languages and operations that you can't imagine , Readers can do their own research on .
Suppose you have the following scenario , The name of a class is in
project Part of the view is blocked .
You want to see the name of the class completely , What to do . Generally use the mouse to move the split line , But it's too inefficient . have access to
alt+1 Focus your mouse on
project In the view , Then use it directly
ctrl+shift+ Left and right arrows To move the split line .
ctrl+shift+enter In fact, it means
Finish for you It means , Not just for semicolons . for instance ：
This code , We also need to if Statements with braces can be compiled through , At this time, you directly input
IDEA It will automatically help you finish , With braces .
IDEA The refactoring function of is very powerful , But sometimes , In a single class , If you just want to batch modify a certain text , You don't have to use refactoring . for instance ：
In the above code , Yes 5 A place used rabbitTemplate Text , How to modify in batch ？ The first is to use
rabbitTemplate This text , Then use... In turn 5 Time
alt+j Shortcut key , Select... One by one , So all five texts are selected and highlighted , At this time, you can directly batch modify .
Remove the navigation bar , Because I don't usually use much .
You can remove the red navigation bar , Give Way
IDEA It's a little cleaner . Use
alt+v, Then remove the
Navigation bar that will do . After removing the navigation bar , If you still use it occasionally , Direct use
alt+home You can temporarily display the navigation bar .
If you want this temporary navigation bar to disappear , Use it directly
esc The shortcut key can .
When there are so many packages and classes in the project , Sometimes we want to know that the current class is project Where is the view located .
In the picture above
DemoIDEA in , How do you know it's in
spring-cloud-config Where in the project ？ You can use it first
Select in View , And then choose
Project View Medium
Project, enter , You can immediately locate the class .
Then how to
project Jump back to the code ？ You can use it directly
esc sign out
project View , Or use it directly
F4, Jump into the code .
If you vaguely remember a method name with a few letters , Want to be in
IDEA Find it out , What can I do ？ Use it directly
symbol To find out . for instance ：
You want to find checkUser Method . Direct input
user that will do .
If you remember a method in a business class , You can also use the initial to find the class , Then add a
., It's OK to type the method name again .
ctrl+shift+n after , Use
/, Then enter the directory name .
Automatic generation not null such if Judge , stay
IDEA There are many ways , One way you may not have thought of .
When we use rabbitTemplate. after , Direct input
notnull And return ,
IDEA So that it can automatically generate if Determine the .
This is also a function I like very much , You can find the code block matching the template according to the template . for instance ：
Want to find everything in the whole project try catch sentence , however catch There is no exception handling in the statement .
catch The statement does not handle exceptions , It's extremely dangerous . We can
IDEA It's easy to find all this code .
ctrl+shift+A The shortcut key pops up action box , Then input
Search Structurally after , enter , Jump to template view .
Existing Templates Button , choice
try Templates . In order to find out catch There is no code block to handle exceptions , We need to configure it
Maximum count Value , Set it to 1.
Edit Variables Button , Modify... In the interface
Maximum count Value .
find Button , You can find out catch There is no code to handle exceptions .
Want to know more ？ Scan the QR code below and follow me The background to reply " technology ", Join the technology group background reply “k8s”, Can claim k8s Information 【 Highlights 】
Point a praise + Looking at , Less bug ????