IDEA工具设置大揭秘:提升你的开发效率

前言


IDEA设置

开发设置


JDK相关设置

项目的JDK设置

1
File-->Project Structure...-->Platform Settings -->SDKs

image-20221206132441000

  • 注1:SDKs全称是Software Development Kit ,这里一定是选择JDK的安装根目录,不是JRE的目录。
  • 注2:这里还可以从本地添加多个JDK。使用“+”即可实现。

out目录和编译版本

1
File-->Project Structure...-->Project Settings -->Project

image-20221206142723854

详细设置

如何打开详细配置界面

显示工具栏

image-20221206143923642

选择详细配置菜单或按钮

image-20221206143954871

image-20221206144015759

系统设置

默认启动项目配置

image-20221206144046646

启动IDEA时,默认自动打开上次开发的项目?还是自己选择? 如果去掉Reopen last project on startup前面的对勾,每次启动IDEA就会出现如下界面:

image-20221206144109047

取消自动更新

1
Settings-->Appearance & Behavior->System Settings -> Updates

image-20221206144150505

默认都打√了,建议检查IDE更新的√去掉,检查插件更新的√选上。

设置整体主题

选择主题

image-20221206144233751

设置菜单和窗口字体和大小

image-20221206144256046

设置IDEA背景图

image-20221206144316634

选择一张合适的图片作为背景,即可。

image-20221206144330750

设置编辑器主题样式

编辑器主题

image-20221206144359012

字体大小

image-20221206144413243

更详细的字体与颜色如下:

image-20221206144429558

1
2
温馨提示:如果选择某个font字体,中文乱码,可以在fallback font(备选字体)中选择一个支持中
文的字体。

注释的字体颜色

image-20221206144500819

  • Block comment:修改多行注释的字体颜色
  • Doc Comment –> Text:修改文档注释的字体颜色
  • Line comment:修改单行注释的字体颜色

显示行号与方法分隔符

image-20221206144603292

代码智能提示功能

image-20221206144626208

IntelliJ IDEA 的代码提示和补充功能有一个特性: 区分大小写 。 如果想不区分大小写的话,就把这个对勾去掉。 建议去掉勾选 。

自动导包配置

  • 默认需要自己手动导包,Alt+Enter快捷键

image-20221206144717320

  • 自动导包设置
    • 动态导入明确的包:Add unambiguous imports on the fly,该设置具有全局性;
    • 优化动态导入的包:Optimize imports on the fly,该设置只对当前项目有效;

image-20221206144757831

设置项目文件编码(一定要改)

image-20221206144823144

说明: Transparent native-to-ascii conversion主要用于转换ascii,显式原生内容。一般都要勾选。

设置控制台的字符编码

image-20221206151123925

修改类头的文档注释信息

image-20221206151318280

比如:

1
2
3
4
5
6
7
8
/**
* ClassName: ${NAME}
* Package: ${PACKAGE_NAME}
* Description:
* @Author 尚硅谷-宋红康
* @Create ${DATE} ${TIME}
* @Version 1.0
*/

常用的预设的变量,这里直接贴出官网给的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
${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 created.
${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.

设置自动编译

1
Settings-->Build,Execution,Deployment-->Compiler

image-20221206151444770

取消双击shift搜索

因为我们按shift切换中英文输入方式,经常被按到,总是弹出搜索框,太麻烦了。可以取消它。

image-20221206151545875

  • 方式1:适用于IDEA 2022.1.2版本

在2022.1版本中,采用如下方式消双击shift出现搜索框:搜索double即可,勾选Disable double modifier key shortcuts,禁用这个选项。

image-20221206151620547

  • 方式2:适用于IDEA 2022.1.2之前版本

双击shift 或 ctrl + shift + a,打开如下搜索窗口:

image-20221206151702061

选择registry…,找到”ide.suppress.double.click.handler”,把复选框打上勾就可以取消双击shift出现搜索框了。

image-20221206151729554

其它设置

  • 是否在单行显式编辑器选项卡(建议去掉勾选)

image-20221206151814439

  • 设置代码样式:比如,设置import显示”*”时的个数

image-20221206151836756

1
2
总结:
以上这些设置看似只是针对当前Project设置的,但是新建的其它Project也是同样适用的。

后记


增进开发效率