IntelliJ IDEA 之二常用配置与使用

大纲

切换主题

更多主题可以从这里获取,主题下载以后,导入主题 (方式一) file –> import setttings –> 选中已下载的主题 Jar 文件 –> 一路确认 –> 重启。IDEA 重启以后,新主题会自动启用。另外一种方式是通过插件来更换主题,例如喜欢黑色主题的话,可以在线安装插件 “Material Theme”,安装完之后重启 IDEA,新的主题就会启用。如果对安装的主题插件不满意,还可以找到此插件,进行卸载并重启 IDEA 即可。默认主题的切换方式如下图:

idea-theme

设置使用鼠标滚轮修改字体大小

勾选此设置后,可以使用 Ctrl + 鼠标滚轮的快捷键来控制代码字体的大小。

idea-font-size

设置鼠标悬浮显示文档提示

idea-mouse-tip

设置自动导包

“Add unambiguous imports on the fly”,表示自动导入不明确的结构,”Optimize imports on the fly”,表示自动优化导入的包。

idea-auto-import

设置显示行号

idea-show-line

设置代码提示忽略大小写

IntelliJ IDEA 的代码提示和补全功能有一个区分大小写的特性,而且默认就是 “First letter only” 区分大小写的。区分大小写的情况是这样的,比如在 Java 代码文件中输入 stringBuffer,IntelliJ IDEA 默认是不会有代码提示或者代码补全的,但是如果输入 StringBuffer 就可以进行代码提示和代码补全。为了方便开发,可以选择不区分大小写,配置方法如下图:

idea-match-case

设置取消单行显示 Tab

在同时打开很多文件的时候,IntelliJ IDEA 默认是把所有打开的 Tab 进行单行显示的。但是多行显示效率比单行显示高,因为单行显示会隐藏超过界面那部分的 Tab,这样找文件很不方便。

idea-show-tabs

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

idea-font-size-spacing

设置当前主题的字体、字体大小、字体行间距

idea-theme-font-size-spacing

设置代码注释的字体颜色

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

idea-comment-color

设置超过指定 import 个数则改为 import *

idea-import-number

修改类头的文档注释信息

常用的预设变量列表如下:

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

idea-class-head-comment

设置项目文件编码

“Transparent native-to-ascii conversion” 主要用于转换 Ascii,一般都要勾选,不然 Properties 文件中的注释显示的都不会是中文。

idea-file-encodings

设置自动编译

Intellij IDEA 默认状态为不自动编译,而 Eclipse 默认为自动编译。

idea-auto-compile

开启省电模式

界面操作路径:File –> Power Save Mode,IntelliJ IDEA 开启省电模式之后会关闭代码检查和代码提示等功能。一般也可认为这是一种阅读模式,如果在开发过程中突然遇到代码文件不能进行代码检查和代码提示,可以检查是否开启了省电模式。

设置文件内容水平或垂直显示

idea-split

设置快捷为 Eclipse 的快捷键

idea-keymap-eclipse

修改快捷键设置

idea-keymap-settings

通过快捷键进行匹配,查看或修改其他功能的快捷键

idea-search-keymap

设置不折叠显示代码

idea-online-methods

设置不检查单词拼写

idea-spelling

导入已有的快捷键配置

当 IntelliJ IDEA 配置好所有自己熟悉的快捷键之后,可以将快捷键的配置导出为 Jar 文件,方便在下次迁移开发环境时无需重新配置。这里给出一份 IntelliJ IDEA 的快捷键配置文件,目前已经将 IntelliJ IDEA 的快捷键都设置为 Eclipse 常用的快捷键,方便 Eclipse 重度用户快速上手使用 IntelliJ IDEA 进行开发。配置文件的下载地址在这里,具体的快捷键说明可以查看图片 1图片 2

idea-import-keymap

取消在线检测更新

idea-cancel-update

取消未使用的方法警告

idea-unused-declaration