如何使用IntelliJ正确导入Java代码样式设置? [英] How to properly import Java code style settings with IntelliJ?
问题描述
我尝试导入 Google的Java代码样式使用IntelliJ。
样式文件包含以下配置:
I tried to import Google's Java code style with IntelliJ.
The style file contains the following configuration:
<code_scheme name="GoogleStyle">
<option name="JAVA_INDENT_OPTIONS">
<value>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
...
</value>
</option>
...
</code_scheme>
但导入后我的设置仍显示
标签尺寸 4(而不是8)
缩进 4(而非2)
延续缩进 8(而不是4)
But after the import my settings still show
Tab size 4 (instead of 8)
Indent 4 (instead of 2)
Continuation indent 8 (instead of 4)
当我导出该样式方案时,然后在输出文件中的值与原始文件中的值相同:
When I export that style scheme then in the output file the values are the same as in the original file:
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
我导入样式的步骤:
- 导航到设置 - > 编辑 - > 代码样式 - > Java
- 点击 Scheme 下拉列表旁边的管理按钮 - > 导入... - > IntelliJ IDEA代码样式XML
- 从 Scheme 下拉列表中选择新选项(称为GoogleStyle)
- 申请
- Navigate to Settings -> Editor -> Code Style -> Java
- Click Manage button next to Scheme dropdown -> Import... -> IntelliJ IDEA code style XML
- From the Scheme dropdown select the new option (called "GoogleStyle")
- Apply
我正在使用IntelliJ IDEA社区2016.2.2
I'm using IntelliJ IDEA Community 2016.2.2
预期的结果是,当我导入样式时,创建的样式方案的缩进大小(等)与代码方案文件中指定的相同。
我该怎么做?
The expected result is that when I import the style then created style scheme has indent size (etc) the same as specified in the code scheme file.
How can I do that?
推荐答案
配置文件中使用的格式似乎与IntelliJ(至少我使用的版本)不同我希望。
It seems that the format used in the configuration file differes from what IntelliJ (at least the version I'm using) expects.
我改变了我的代码设置,导出它们并寻找差异。
设置在输出文件中如下:
I changed my code setting, exported them and looked for differences.
The ident setting were in the output file like so:
<code_scheme name="MyTestStyle">
...
<codeStyleSettings language="JAVA">
<indentOptions>
<option name="INDENT_SIZE" value="2" />
<option name="CONTINUATION_INDENT_SIZE" value="4" />
<option name="TAB_SIZE" value="8" />
</indentOptions>
</codeStyleSettings>
</code_scheme>
导入此文件按预期工作。
Importing this file worked as expected.
这篇关于如何使用IntelliJ正确导入Java代码样式设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!