IDEA:打造最强 IDE,这些配置你知道吗?
微信公众号:1JavaHub
关注 Java 技术。如有问题或建议,请公众号留言。
此处略去安装等一系列操作等,直接进入正文。
本文各项配置均基于 IntelliJ IDEA COMMUNITY 2019.3 版本(社区版足以)。
主题调整
显示内存使用情况
- File -> Settings -> Appearance & Behavior -> Appearance -> Window Options -> 勾选 “Show memory indicator”
添加打开资源管理器到工具栏
- File -> Settings -> Appearance & Behavior -> Memus and Toolbars -> 点开 “Main Toolbar” -> 点击最后一个菜单项 -> 点击 “+” 号 -> Add Action… -> 在弹出的 “Choose Actions To Add” 框中,打开 “Other” -> 拖到最后找到 “Show in Explorer” -> OK
设置编辑器的快捷键
使用 “ctrl + 鼠标滚轮” 调整字体
- File -> Settings -> Editor -> General -> Mouse -> 勾选 “Change font size (Zoom) with Ctrl+Mouse Wheel”
鼠标移动到指定类和方法上显示对应的文档
- File -> Settings -> Editor -> General -> Other (拖到最后) -> 勾选 “Show quick documentation on mouse move”
导包优化
- File -> Settings -> Editor -> General -> Auto Import -> 勾选 “Add unambiguous imports on the fly” 和 “Optimize imports on the fly”
PS:- Add unambiguous imports on the fly:快速添加明确的导入。
- Optimize imports on the fly:快速优化导入,优化的意思即自动帮助删除无用的导入。
显示行号和空白字符
隐藏面包屑
代码补全优化:忽略大小写
编辑器 Tab 使用小字体
- File -> Settings -> Editor -> General -> Editor Tabs -> 勾选 “Use small font for labels”
编辑器 Tab 使用 * 标记有修改的文件
- File -> Settings -> Editor -> General -> Editor Tabs -> 勾选 “Mark modified (*)”
最近打开的编辑器 Tab 显示到最后
- File -> Settings -> Editor -> General -> Editor Tabs -> 勾选 “Open new tabs at the end”
打开的编辑器 Tab 数量限制
- File -> Settings -> Editor -> General -> Editor Tabs -> Closing Policy -> 根据实际情况修改 “Tab limit” 的大小
编辑器字体调整
- File -> Settings -> Editor -> Font -> 根据实际情况选择 “Font” 和 “Fallback font”
- File -> Settings -> Editor -> Color Scheme -> Color Scheme Font -> 根据实际情况选择 “Font” 和 “Fallback font”
PS:如果有些字体没有显示,去掉 “Show only monospaced fonts” 的勾
调整颜色配置
- File -> Settings -> Editor -> Color Scheme -> Scheme -> 根据实际情况选择
默认使用空格代替 tab
导包优化:导包避免使用 * 号
- File -> Settings -> Editor -> Code Style -> Java -> Imports -> 调整 “Class count to use import with ‘*‘” 和 “Names count to use static import with ‘*‘” 的大小
导包优化:调整导包的顺序,和 Eclipse 保持一致
- File -> Settings -> Editor -> Code Style -> Java -> Imports -> Imports Layout,按如下顺序进行调整plaintext
1
2
3
4
5
6
7
8
9
10
11<blank line>
import java.*;
<blank line>
import javax.*;
<blank line>
import com.*;
<blank line>
import all other imports
<blank line>
import static all other imports
<blank line>
添加创建类注释模板
- File -> Settings -> Editor -> File and Code Templates -> Files -> 根据实际情况调整注释模板plaintext
1
2
3
4
5
6
7
8
9/**
* Copyright (C), 2010-${YEAR}, Company Name.
* Created by ${USER} on ${DATE}.
*
*
*
* @author ${USER}
* @date ${DATE} ${TIME}
*/
调整文件编码为 UTF-8
- File -> Settings -> Editor -> File Encodings -> 调整 “Global Encoding”、“Project Encoding”、“Default encoding for properties files” 的编码为 UTF-8
在左侧 Project 视图隐藏对应类型的文件
- File -> Settings -> Editor -> File Types -> 在 “Ignore files and folders” 处添加对应的类型,例如:*.iml;.classpath;.settings;.project;
插件推荐
- File -> Settings -> Plugins
- Alibaba Java Coding Guidelines:阿里编码规约检查插件
- Atom OneDark Theme:清爽的 Atom 主题插件
- Background Images Plus +:背景图片插件
- Maven Helper:Maven 插件
- Power Mode II:炫酷的打字特效插件
配置 Git
配置 Maven
- File -> Settings -> Build,Execution,Deployment -> Build Tools -> Maven
- Maven home directory:Maven 程序根目录
- User settings file:settings.xml 配置文件路径
- Local repository:本地仓库路径
项目自动编译
调整 Toolbar 和 Navigation Bar
- View -> Appearance -> 勾选 “Toolbar”,去掉 “Navigation Bar”
PS:如果手抖将 “Main Menu” 给隐藏了,可以在 “C:\Users\username.IdeaIC2019.3\config\options\ui.lnf.xml” 文件中修改 “SHOW_MAIN_MENU” 为 “true”,并重启 IDEA
Getter and Setter 自动添加注释
- alt + insert -> 选择 “Getter and Setter”
- Getter Template 和 Setter Template 的默认值都是 Intellij Default,点击后面的 “…”
- 点击左上角 “+”,在弹出框中输入模板名称
- 复制默认值里面的代码到新加的模板中,并在开头添加注释模板,最后的代码如下
Getter
plaintext
1 | /** |
Setter
plaintext
1 | /** |
不显示调用方法的参数名提示
- File -> Settings -> Editor -> Inlay Hints -> Java -> Parameter hints -> 不勾选 “Show parameter hints for”
代码折叠:折叠仅一行的方法
- File -> Settings -> Editor -> General -> Code Folding -> Java -> One-line methods(不勾选则不折叠)
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 JavaHub!
评论