IntelliJ IDEA神器使用技巧

说明:详情请参考慕课网课程:IntelliJ IDEA神器使用技巧:http://www.imooc.com/learn/924(感谢课程作者:闪电侠)

推荐:

1. 课程老师(闪电侠)IDEA快捷键总结文档:https://github.com/lightningMan/config/blob/master/intellij/shortcut-readme.md

2. 另一位学习课程的同学(夜空中最亮的庆)的总结,也写的用心:https://www.jianshu.com/p/131c2deb3ecf

3. 下面是我自己总结:

快捷键


文件操作:
Ctrl+Alt+insert: 创建Class文件,文件夹...
F5:复制文件
F6:移动文件
Ctrl + C: 复制文件名
Ctrl + Shift + C:复制文件路径
Ctrl + V:粘贴
Ctrl + Shift + V:批量粘贴(调用剪切板)
Ctrl + Alt + T: Surround With, 可用于try...catch,如图

 

 
 
智能返回:
Ctrl+Alt+V:智能返回响应类型结果

行操作:
1. Shift+Enter: 向下插入一行
2. Ctrl+Alt+Enter: 向上插入一行

列操作
1. Alt+鼠标左键:列编辑
2. Ctrl+Alt+Shift+J: 选中所有被选中的符号(例如:选中所有的分号)
3. Ctrl+向右箭头:移动光标到下一个单词
4. Ctrl+Shift+向右箭头:移动光标到下一个单词并选中
5. Shift+Home: 移动光标到行首并选中
6. Shift+End: 移动光标到行尾并选中
7. F2/Shift+F2: 快速向下(上)定位到错误行
8. Alt+insert: 生成构造方法,get/set方法,覆写方法,toString()...
9. Alt+enter: 智能提示
Postfix:后缀,Postfix(for, sout, field(name.field)...还有很多默认的,后续再研究)
1. 100.for
2. date.sout
3. "String".r + 向上箭头
4. name.nn(非空判断), name.null(为空判断)
 1 import java.util.Date;
 2 
 3 /**
 4  Postfix:后缀,Postfix(for, sout, field(name.field)...还有很多默认的,后续再研究)
 5   1. 100.for
 6   2. date.sout
 7   3. "String".r + 向上箭头
 8 
 9   4. name.nn, name.null
10 
11  */
12 public class Postfix {
13 
14     public static void main(String[] args) throws InterruptedException {
15         for (int i = 0; i < 100; i++) {
16             Date date = new Date();
17             Thread.sleep(1000);
18             System.out.println(date);
19         }
20     }
21     private String name = "zs";
22     private int age = 20;
23 
24     private String getStr(){
25         if (name != null) {
26 
27         }
28         if (name == null) {
29 
30         }
31         return "string";
32     }
33 
View Code
Alt+enter:智能提示
 1 import java.util.List;
 2 
 3 /**
 4  AltEnter: 智能提示
 5     注:ctrl+alt+insert: 创建Class文件,文件夹...
 6     1. 自动创建函数
 7     2. List replace
 8     3. 字符串的format或者build
 9     4. 单词拼写
10     5. 导包
11  */
12 public class AltEnter {
13     /**
14      * 1. 自动创建函数
15      * 2. List replace
16      * @param args
17      */
18     public static void main(String[] args) {
19         fuc1();
20         fun3();
21     }
22 
23     private static String fuc1() {
24 
25         return "string";
26     }
27 
28     /**
29      * 2. List replace
30      * @param list
31      */
32     private static void fun2(List<String> list) {
33         int i = 0;
34         while (true) {
35             if (!(i < list.size())) break;
36 
37             i++;
38         }
39     }
40 
41     /**
42      * 3. 字符串的format或者build
43      */
44     private static void fun3() {
45         String name = "zs";
46         int age = 20;
47         String x1 = String.format("name: %s, age: %d", name, age);
48         String x2 = new StringBuilder().append("name: ").append(name).append(", age: ").append(age).toString();
49         System.out.println(x1);
50         System.out.println("---------------");
51         System.out.println(x2);
52 
53     }
54 }
View Code
重构与抽取:
重构:
Shift+F6:重构变量
Ctrl+F6:重构方法(或Alt+Enter)
抽取:
Ctrl+Alt+V:抽取变量
Ctrl+Alt+C:抽取静态常量
Ctrl+Alt+F:抽取成员变量(字段)
Ctrl+Alt+P:抽取方法参数
Ctrl+Alt+M:抽取方法
 1 /**
 2  * 重构变量与重构方法
 3  */
 4 public class RefactorDemo {
 5     public static final String DEFAULT_NAME = "chris";
 6     private int age;
 7 
 8     /**
 9      * 重构变量: shift+F6
10      */
11     public static void fun(String firstName) {
12         System.out.println(firstName);
13         System.out.println(firstName);
14         System.out.println(firstName);
15         System.out.println(firstName);
16         System.out.println(firstName);
17         fun2("Lee", DEFAULT_NAME);
18     }
19     /**
20      * 重构方法: ctrl+F6或者alt+enter
21      */
22     public static String fun2(String firstName, String lastName) {
23 
24         System.out.println(firstName+lastName);
25         return firstName+lastName;
26     }
27     /**
28      * 抽取变量:Ctrl+alt+v
29      */
30     public static void extract1() {
31         String name = DEFAULT_NAME;
32         System.out.println(name);
33         System.out.println(name);
34         System.out.println(name);
35         System.out.println(name);
36         System.out.println(name);
37         System.out.println(name);
38         System.out.println(name);
39     }
40     /**
41      * 抽取静态常量:Ctrl+alt+C
42      */
43     public static void extract2() {
44         // public static final String DEFAULT_NAME = "chris";
45         System.out.println(DEFAULT_NAME);
46         System.out.println(DEFAULT_NAME);
47         System.out.println(DEFAULT_NAME);
48         System.out.println(DEFAULT_NAME);
49     }
50     /**
51      * 抽取成员字段:Ctrl+alt+F
52      */
53     public void extract3() {
54         age = 20;
55         extract4(age);
56         System.out.println(age);
57     }
58 
59     /**
60      * 抽取方法参数:Ctrl+alt+P
61      * @param length
62      */
63     public void extract4(int length){
64         System.out.println(length);
65         System.out.println(length);
66         System.out.println(length);
67         System.out.println(length);
68         System.out.println(length);
69     }
70 
71     /**
72      * 抽取方法:Ctrl+alt+M
73      */
74     public void extract5(){
75         init();
76         sevice();
77         destroy();
78     }
79 
80     private void destroy() {
81         System.out.println("extract method");
82         System.out.println("extract method");
83     }
84 
85     private void sevice() {
86         System.out.println("extract method");
87         System.out.println("extract method");
88     }
89 
90     private void init() {
91         System.out.println("extract method");
92         System.out.println("extract method");
93     }
94 }
View Code

 Git集成与版本控制:

annotate:鼠标右键,查看当前行代码是由何人,何时编辑及修改
Ctrl+Alt+Shift+向上箭头/向下箭头: 上次修改的地方previous change
Ctrl+Alt+Z:撤销,可以针对于行,文件,文件夹
local history: 本地修改历史
show history: 查看历史
show label: 查看标记历史
断点调试(直接界面操作):
Ctrl + F8:添加/取消断点
Shift + F10:运行
Shift + F9:调试
F8:单步运行
F9:调到下一个断点
Ctrl + Shift + F8:查看所有断点
Mute Breakpoints:禁止所有断点
Ctrl + Shift + F8:条件断点
Alt + F8:动态求值
Alt + F9:运行到指定行(Run to Cursor)
F2:动态改变值
Ctrl + Shift + F9:上下文运行,用在单元测试中方便
Alt + Shift + F9:运行最近的文件
结构图:
Ctrl + F12:查看结构图
Ctrl + H:查看类的继承结构体系
Ctrl + Alt + U:查看类的继承结构体系图
Ctrl + H:查看方法调用谁,被谁调用

转载于:https://www.cnblogs.com/chris0710/p/8984589.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值