最特殊的快捷键 Alt + Enter 介绍
说明
- 这是一个非常特殊的快捷键,有必要拿出来单独讲。
- 强烈注意:此快捷键跟光标所在位置有着很严重关联关系,光标放的位置不同,使用此快捷键出来的菜单选项完全不一样。
- 可以从几个思路:Java 类、JSP、HTML、JavaScript、CSS、SQL 等文件类型
- 下面演示的各个功能是基于:IntelliJ IDEA 2016.1.1,如果你使用早期版本,可能不一定有对应的功能。
智能辅助
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-1.gif)
- 在 接口类 中,如果光标当前所在的方法,已经在 接口实现类 中生成了,则此快捷键的效果是跳转。
- 在 接口类 中添加一个方法后,让该 接口实现类 也跟着生成
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-2.gif)
- 在 接口实现类 中添加一个方法后,让该 接口类 也跟着生成
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-3.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-4.gif)
- 对当前光标所在类,创建子类,常用在对接口生成接口实现类
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-5.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-6.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-7.gif)
- 添加 doc,只能把光标放在方法名或是变量名等这类元素上才会有
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-8.gif)
- 把自己造的单词加入词库中,让拼写单词检查错误的波浪线效果消失。
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-9.jpg)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-10.gif)
- 快速移除当前类所继承的接口,并且同时清空已经写好的该接口所有的 Override 方法。
- 光标只能方式 接口实现类 上的 接口对象单词 上才可以实现。
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-11.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-12.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-13.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-14.gif)
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-15.gif)
- 根据 Language Level 级别不同,JDK 特性不同,给不同意见。Language Level 的含义在其他章节有讲过。
![智能辅助](https://img.cntofu.com/book/IntelliJ-IDEA-Tutorial/images/hotkey-alt-enter-introduce-16.gif)
- 给 Hibernate 的 Entity 对象分配数据源,从而产生一系列智能功能