默认快捷键
mac
# 格式化代码
Command + Option + L
# 去除无用的引用
control +option + o
# 快速生成测试类
command + shift + t
# 窗口最小化
command + m
# 将选中的代码变成 try catch ,synchronized 等语句的代码块
option + command + t
# 选中代码块封装成方法
option + command + m
commad + 1 ~ =
# 打开 Bookmarks
command + 2
# 缩略显示代码
command + -
window
Alt+7 快速查看当前类中的所有方法
Ctrl+Alt+L 代码格式化快捷键
Alt + 1 左侧 项目 目录 最大最小化
Ctrl + r 当前页面 替换
Ctrl + Shift + f 全局 查找
Ctrl + Shift + r 全局 替换
Ctrl + Shift + t 需要做测试的类的当前窗口 快速自动生成Junit测试类
Ctrl+alt + t 选中代码,按快捷键可直接try catch 此段代码
Ctrl+alt + m 抽取重复的方法
Ctrl + Shift + u 大小写字母转换
Ctrl + Shift + c 复制文件或文件夹绝对路径
系统常用设置
自动导入包和删除包
add unambiguous imports on the fly 和 optimize imports on the fly 两个选项顾名思义,一个是自动导包,一个是自动移除无用 import
FIleType过滤
例如忽略文件 .idea 文件的显示
字符编码设置
Lombok需要启用注释处理
Java 快捷语法
也可自定义
public static Integer test() {
boolean flag = true;
//flag.if
if (flag) {
}
//flag.else
if (!flag) {
}
//flag.while
while (flag) {
}
Integer id = 1;
//id.nn
if (id != null) {
}
//id.null
if (id == null) {
}
//快速输出
String str = "11";
//str.souf
System.out.printf("", str);
//str.sout
System.out.println(str);
//str.soutv
System.out.println("str = " + str);
//快速写异常
//int a = 10/0.try
try {
int a = 10 / 0;
} catch (Exception e) {
e.printStackTrace();
}
//使用var直接返回值
//test1().var
List<Integer> test = test1();
//Sets.newHashSet().var
HashSet<Object> objects = Sets.newHashSet();
List<Integer> list = Arrays.asList(1, 2, 3);
//list.for
for (Integer integer : list) {
}
//list.fori
for (int i = 0; i < list.size(); i++) {
}
//list.forr
for (int i = list.size() - 1; i >= 0; i--) {
}
//快速返回
int result = 1;
//result.return
return result;
}
public static List<Integer> test1() {
return Lists.newArrayList();
}