我已为google-java-format
安装了IntelliJ
插件,我已启用该插件。当我格式化代码时,我的java代码缩进了2个空格。如何更改google java formatter插件设置以更改为4个空格?
答案 0 :(得分:2)
首先,我从here禁用了IntelliJ
google-java-format plugin.Downloaded IntelliJ-java-google-style.xml
,并修改了缩进尺寸属性,如下所示。在IntelliJ中导入此样式后,我可以缩进到4个空格。要导入代码样式XML,请参阅此link
<codeStyleSettings language="CSS">
<indentOptions>
<option name="INDENT_SIZE" value="4" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="4" />
</indentOptions>
</codeStyleSettings>
答案 1 :(得分:0)
我可以通过在google-java-format插件设置中选择 Android开放源代码项目(AOSP)样式来更改为4位缩进:
这两种样式之间唯一的区别似乎是AOSP将间距加倍为4,而不是2: https://github.com/google/google-java-format/blob/master/core/src/main/java/com/google/googlejavaformat/java/JavaFormatterOptions.java#L37