1. 操作步骤

IDEA 设置 tab 为 4 个空格的规范

2. 解释说明

a. Indent

  • Indent(缩排)设置为 4,代表按一个 tab 为 4 个空格,并且自动整理格式也是 4 个空格一缩进。

b. Use Tab Character

  • 不要选 Use tab character,否则 tab 出来的空间不能换成空格。
  • 阿里巴巴 Java 开发规范中规定,IDEA 设置 tab 为 4 个空格时,请勿勾选 Use tab character;而在 Eclipse 中,必须勾选 insert spaces for tabs。

3. 补充:自动排版

  • 可以按 ctrl + alt + L 整理格式,如果不想让自动格式整理打乱自己整理的格式,可以用 edit -> convert Indents 来将缩进的 tab 转换为空格。操作如下:
    IDEA 设置 tab 为 4 个空格的规范

原文链接:https://qwert.blog.csdn.net/article/details/105789861

相关文章: