IDE Features Trainer 官方学习idea一个插件,熟悉常用的idea快捷键使用 https://plugins.jetbrains.com/plugin/8554-ide-features-trainer
基础编辑操作
1、动作(触发事件)
1.1、按 shift+command +A (可能出现快捷键冲突)
- 系统快捷键冲突:
- 系统偏好设置–> 键盘–> 快捷键–>服务,取消勾选
- 其他软件冲突(比如钉钉截图)就是使用这个快捷键,可以变更这个快捷键(一般打开软件配置,差不多快捷键都是 command+, )
- 正常按 shift+command+A 将会出现
1.2、输入about,选择不带问号的about,回车(return或enter)
- 出现如下结果
1.3、再次按shift+command+A , 然后输入 line num, 同时可以进行 on/off切换(打开/关闭 显示行数)文件就不会显示行数
- 其实你在上面的界面可以按 option +回车键 ,来自定义对应行为的快捷键
1.4、按 control + shift + -> (右方向键)
- 进行下章节学习 (也就跳转到代码补全章节)
2、选择操作
2.1、按 option + shift + -> (右方向键) 快捷键
- 选择单词和代码块
2.2、按 option + 上方向键
-
按9次 option +上方向键 , 观察变化
2.3、按 option + 下方向键
- 逐渐缩小选择范围(刚好与 option+上方向键 相反)
2.4、command+A
- 全选操作
3、注释行
3.1、command + /
- 单行注释,也就在前面加//
3.2、在光标定位到已经注释11行,再次按 command + /
- 取消注释
3.3、选择多行,然后按 command + / 注释多行
3.4、按 shift + command + / 多行注释
4、删除行
4.1、按 command + delete , 删除一行
4.2、按command + Z , 撤销删除操作
5、复制一行
5.1、按 comand + D
- 复制一行
5.2、选择多行,然后按 command +D
- 多行复制(选择2行以上)
6、移动操作
6.1、按 option+shift+下方向键
- 将当前行向下移动一行
6.2、按 option+shift + 上方向键
- 将当前行往上移动一行
6.3、按 command+shift + 上方向键
- 将当前方法整体向上移动一行
7、折叠操作
7.1、command + “-” (command + 减号)
- 折叠单个方法
7.2、 comand + “+” ( command + 加号)
- 展开单个方法
7.3、shift + command + “-” ( shift + command + 减号)
- 折叠所有方法
7.4、shift + command + “+” (shift + command + 加号)
- 展开所有方法
8、选择多个相同字符串
8.1、按 option + G
8.2、再按一下 option + G
-
显示两个编辑光标(也就是同时编辑多个)
8.3、按 shift + option + G
- 取消最后一个选择字符串
8.4、按 command + option + G
- 选择所有匹配字符串
8.5、输入 td, 替换所有的th字符串
代码补全
##1、基础代码补全
1.1、键盘输入Ran , 然后回车(enter 或return)
1.2、键入control + 空格
-
系统快捷键和idea快捷键冲突了,所有解决办法就是去掉系统这个快捷键
-
系统偏好设置–> 键盘–> 快捷键–>输入法, 取消勾选”选择上一个输入法“ (其他类似冲突也是这样解决)
-
control + 空格 快捷键正常
1.3、选择i直接回车(enter或return)
1.4、command + shift + return ( 自动补全,主要补全分号和括号)
1.5、按两次 (control+空格)快捷键 (会有更多关于这个静态常量提示)
1.6、同时你可以按方向键<- 或-> 移动光标来匹配字符
- 示例展示是全部匹配,也就光标在E字母后面
2、类型智能补全
2.1、按 control+shift + 空格 快捷键
-
弹出一个手写输入,类似系统快捷键冲突解决
-
系统偏好设置–> 键盘–> 快捷键–>键盘, 由于"显示/隐藏手写输入" 前面没有复用选框,只能修改快捷键,单击快捷键的值,此时变成可编辑状态,按下你想要变更快捷键,(示例使用:fn+P)
-
正常按control+shift + 空格 快捷键,自动根据类型匹配可选项,然后回车
2.2、按两次 control+shift+空间 快捷键,根据类型自动匹配返回值存在方法 , 选择合适回车(enter 或者return)
3、后缀补全方式(表达式)
3.1、键入点(".")
-
可以输入if,然后回车
-
还一个经常用到应该是.var ,定义本地变量名(特别是如果变量类型特别长时候,特别方便,可以每个去试一下),".field"就是定义成员变量
4、语句补全
4.1、按快捷键:shift+command+回车 , 自动补全{}
-
同时光标切换到{} 的中间
-
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-a3hVR13e-1615205685179)(/Users/liangchen/Library/Application%20Support/typora-user-images/image-20210302191203766.png)]
4.2、输入if 之后,按shift+command+回车
- 自动补全"(){}" ,同时光标定位在"()" 中
4.3、输入"i % j == 0" ,按shift+command+回车
4.4、输入"isPrime = false; break", 按shift+command+回车
- 自动补全分号
5、Tab键自动补全
5.1、按 control+空格
-
推荐常量值
5.2、选择DO_NOTHING_ON_CLOSE,然后按 tab 键
重构
1、重命名
1.1、光标定位到 deviceName上
-
输入 shift + F6, 输入 tableName
1.2、光标定位到stylus, 输入pencil
-
输入 shift + F6, 输入 pencil
-
确定就可以了
-
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EQtPRzE7-1615205685186)(/Users/liangchen/Library/Application%20Support/typora-user-images/image-20210302205255562.png)]
2、提取局部变量和成员变量
2.1、按 option + command + V
3、提取方法
3.1、按 option + command + M
-
输入 init 方法名
4、提取常见操作
4.1、按 option + command + C
4.2、按 option + command + M
- 提取方法
4.3、按 option + command + P
- 变成方法入参
4.4、按 option + command + V
- 选择 new BufferedReader(in) , 按 option + command +V
代码帮助
1、代码格式化
1.1、按 option + command + L
- 格式化选择代码
1.2、如果不选择任何数据,按option + command +L
- 格式化整个文件
2、参数信息
2.1、按 command + P
- 提示方法的参数信息,输入 175, 100
3、快速弹出框
3.1、按 F1
3.2、按 option + 空格
- 预览方法
##4、编辑代码帮助
4.1、按 F2
- 定位错误位置(光标移到对应位置)
4.2、按 command + F1
- 查看错误描述
4.3、按 option + 回车
- 自动解决异常提供方案 , 抛出异常或try catch异常
4.4、按 option + command + T
-
代码选择包裹的结构
-
在finally 中输入 fileReader.close();
4.5、按 shift + command + F7
- 高亮显示当前变量使用位置
导航
1、跳转到源码
1.1、按 command + 下方向键
- 跳转到源码位置,(也可以按住 command + 单击)
2、声明和实现
2.1、按 command + B
- 跳转到声明的类型或接口
2.2、按 option + command + B
- 查看实现类
3、文件结构
3.1、按 command + F12
- 预览文件结构(对于复杂文件)
4、下一个/上一个 匹配项
4.1、按 command + F
- 查找字符串
4.2、按 回车 或 command +G
- 查看下一个匹配项
4.3、按 shift + command + G
- 查看上一个匹配项
4.4、按 comand + G
- 选择字符串,然后按command+G
- 查看匹配下一个项
4.5、按shift + command + G
-
查看上一个匹配项
-
恭喜你完成训练