初次使用IntelliJ IDEA的常用配置

说明

IntelliJ IDEA是目前做Java开发很流行的集成开发环境,有很多人性化的设置。IntelliJ IDEA分为旗舰版和社区版,其中旗舰版的功能更全,但是需要付费使用。当然,不想付费的话,也有一些其他办法(你懂的)。
初次使用时,可以进行一些配置,方便我们的使用。本配置参考了B站的尚硅谷java教程
首先进入设置界面,点击File->Settings,或工具栏图标,或快捷键Ctrl+Alt+S
初次使用IntelliJ IDEA的常用配置
初次使用IntelliJ IDEA的常用配置
目录结构如下:
初次使用IntelliJ IDEA的常用配置
下面逐一进行设置。

1 Appearance & Behavior

1.1 设置主题

初次使用IntelliJ IDEA的常用配置
这里默认提供了三套主题:这里可以根据自己的喜好进行选择。

1.2 设置窗体及菜单的字体及字体大小 (可忽略)

初次使用IntelliJ IDEA的常用配置
这一步设置的不是代码字体的大小,而是菜单字体,基本在体验上没有太大影响,因此可忽略。

1.3 可以通过插件更换主题

喜欢黑色主题的话,还可以下载插件:Material Theme UI
初次使用IntelliJ IDEA的常用配置
点击按钮以后,在联网环境下搜索如下 的插件 安装 重启 IDEA 即可:
初次使用IntelliJ IDEA的常用配置
如果对安装的主题插件不满意,还可以找到此插件,进行卸载重启 IDEA 即可。
关于插件这个话题,有必要可以单独说明一下,这里主要是初次使用时的配置,不再赘述。

2 Editor-General

2.1 设置鼠标悬浮提示

初次使用IntelliJ IDEA的常用配置

2.2 设置自动导包功能

初次使用IntelliJ IDEA的常用配置
Add unambiguous imports on the fly :自动导入不明确的结构
Optimize imports on the fly 自动帮我们优化导入的包

2.3 设置显示行号和方法间的分隔符

初次使用IntelliJ IDEA的常用配置
Show line numbers :显示行数。
Show method separators 显示方法分隔线 。这种线有助于我们区分开方法,所以建议勾选上。

2.4 忽略大小写提示

初次使用IntelliJ IDEA的常用配置
这里我使用的是2019.3版的IDEA,直接将Match case取消勾选就行。
初次使用IntelliJ IDEA的常用配置
IntelliJ IDEA 的代码提示和补充功能有一个特性:区分大小写。默认就是First letter区分大小写的。
比如我们在 Java 代码文件中输入 stringBuffer 。IntelliJ IDEA 默认是不会帮我们提示或是代码补充的,但是如果我们输入StringBuffer 就可以进行代码提示和补充。
如果想不区分大小写的话,修改一下即可。

2.5 设置取消单行显示 tabs 的操作

初次使用IntelliJ IDEA的常用配置

3 Editor-Font

3.1 设置默认的字体、字体大小、字体行间距

初次使用IntelliJ IDEA的常用配置

4 Editor-Color Scheme

4.1 修改代码中注释的字体颜色

初次使用IntelliJ IDEA的常用配置
Doc Comment Text 修改文档注释的 字体 颜色
Block comment 修改多行注释的字体颜色
Line comment 修改单行注释的字体颜色

5 Editor-Code Style

5.1 设置超过指定 import 个数,改为 * 可忽略

初次使用IntelliJ IDEA的常用配置

6 Editor-File and Code Templates

6.1 修改类头的文档注释信息

初次使用IntelliJ IDEA的常用配置
常用的预设的变量,这里直接贴出官网给的:

变量 意义
${PACKAGE_NAME} the name of the target package where the new class or interface will be created.
${PROJECT_NAME} the name of the current project.
${FILE_NAME} the name of the PHP file that will be created.
${NAME} the name of the new file which you specify in the New File dialog box during the file creation.
${USER} the login name of the current user.
${DATE} the current system date.
${TIME} the current system time.
${YEAR} the current year.
${MONTH} the current month.
${DAY} the current day of the month.
${HOUR} the current hour.
${MINUTE} the current minute.
${PRODUCT_NAME} the name of the IDE in which the file will be cre ated.
${MONTH_NAME_SHORT} the first 3 letters of the month name. Example: Jan, Feb, etc.
${MONTH_NAME_FULL} full name of a month. Example: January, February, etc.

7 Editor-File Encodings

7.1 设置项目文件编码

初次使用IntelliJ IDEA的常用配置
说明:Transparent native to ascii conversion 主要用于转换 ascii ,一般都要勾选,不然 Properties 文件中的注释显示的都不会是中文。

8 Build,Execution,Deployment

8.1 设置自动编译

初次使用IntelliJ IDEA的常用配置

9 设置代码水平或垂直显示

初次使用IntelliJ IDEA的常用配置
同时查看多份代码时,会很方便。