idea 配置和常用快捷键

idea配置

1. 设置SDK及SDK编译版本、字体、编码

file -> Project Structure -> ProjectSdk

file -> settings -> 搜索font、encoding,分别设置字体、编码

搜索功能真好用...

  • 类似的,设置注释模板时,搜索"template" 就能找到相应界面设置
2. 配置maven

file -> settings 搜索框搜索maven ,将maven的Maven home directory设置成自己的;

default settings: idea全局配置(或 新点的版本没有default settings 变成settings for new project) 全局配置;
settings:当前项目配置

3. 设置代码编译java版本

file -> other setting -> settings for new project 搜索Java compl,将project bytecode version 设置为8,全局配置编译版本为1.8

file -> project structure -> 将本次打开的项目编译版本设置为1.8

修改pom,添加插件指定maven 编译版本:

官方文档:http://maven.apache.org/components/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-complier-plugin</artifactId>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <encoding>UTF-8</encoding>
    </configuration>
</plugin>
4. 配置git

file -> settings -> 搜索git -> 设置git.exe目录

5. 修改配置文件、缓存文件的位置

idea对项目文件做了索引,以加快查找速度。创建索引、加载缓存等都需要消耗时间。

索引、缓存文件默认保存在C盘 userhome下

idea.system.path=${user.home}/.IntelliJIdea/system

随着使用idea频率的增高,system文件会变大。如果C盘空间不足,可以修改到其他盘

IntelliJ IDEA 2018.3.1\bin\idea.properties

  • idea.system.path
  • idea.config.path

补充一点,idea64.exe.vmoptions/idea32.exe/vmoptions分别是64/32位idea的配置文件。在这里配置的是虚拟机参数等。例如,加用户名

-Duser.name=xxx

6. 乱码
  • 乱码的文件中右键 -> file encoding -> UTF-8

  • 设置项目编码:file -> settings -> file encodings -> global encoding -> utf-8

  • 设置全局编码:file -> other settings -> default/settings for new project -> file encodings -> 搜索"file encodings" -> global encoding -> utf-8

  • 实在不行:到IntelliJ IDEA 2018.3.1\bin\idea64.exe.vmoptions

-Dfile.encoding=UTF-8

7. 创建多模块项目

右键父项目-> New Module -> quickstart -> 填入ArtifactId

每个模块都是一个独立的maven工程,拥有自己的pom

8. 常用快捷键
  • Ctrl+Z 撤销

  • Ctrl+Shift+Z 撤销 "撤销" (冲正)

  • Ctrl + D 复制当前行并粘贴到下一行

  • Ctrl + Y 删除当前行

  • idea 不用选中也可以复制、剪切。Ctrl + C/X 自动复制/剪切 光标所在行

  • 查找:

    • Ctrl+F : 当前文件中查找
    • double Shift: 全局查找文件(类文件等文件)
    • Ctrl + Shift + F : 全局查找文本
    • Ctrl + R 当前文件检索替换
    • Ctrl + Shift + R 全局查找替换
    • Alt + F7 查找类被调用的地方 (类似eclipse中call hierarchy)
    • Ctrl + Alt + B 快速定位当前方法的实现
  • Alt + insert 生成构造方法、get/set、实现接口方法等代码

  • 块注释 : Ctrl + Shift + /

  • 格式化(format) : Ctrl + Alt + L

  • 导包优化import : Alt + Ctrl+ O

  • 重命名文件: Shift + F6

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容