IDEA 代码风格设置

1.类注释

File -> Settings -> Editor -> File and Code Templates -> Includes -> FileHeader

 /**     
  * @describe: TODO 
  * @author: zhuCw
  * @date: ${DATE} ${TIME}
  */

2.缩进

采用4个空格缩进,或者设置tab键为4个空格, 不能勾选Use tab character,参考下图

File -> Setting -> Editor -> Code Style -> java -> Tabs and Indents

3.插件

3.1 google-java-format (格式化代码)

File -> Setting -> Marketplace -> 搜索google-java-format -> install -> Disable

3.2 save actions (保存格式化)
  • 安装 :File -> Setting -> Marketplace -> 搜索 save actions -> install -> Disable

  • 设置 File -> Setting -> Other Setting -> Save Actions

    • 保存自动格式化
    • 去掉多余imports
    • 保存时格式化整个文件
    • 修改CodeStyle为Android Open Source Project(AOSP) stype 因为 goole style 缩进为两个空格与阿里推荐4个空格冲突


3.3 Alibaba Java Coding Guidelines plugin (阿里代码规范扫描)
  • 安装:File -> Setting -> Marketplace -> 搜索 Alibaba Java Coding Guidelines plugin -> install -> Disable

  • 扫描方法

    选中扫描的项目 -> 右键

  • 扫描结果

4.导入Setting

  • setting文件 在百度云盘
链接:https://pan.baidu.com/s/1azh6PAVWgiGWzpotaJV7eA 
提取码:dg48 

File -> Settings -> Code Style -> 设置图标 -> import Scheme

posted on 2019-04-09 15:59  朱春旺  阅读(3160)  评论(0编辑  收藏  举报