[英]IDEA - How can I place braces on the next line for .gradle files?
In the Code Style settings of IntelliJ IDEA, there aren't any subcategories for .gradle
files (eg, build.gradle
), and under Other File Types , there isn't any option to modify brace placements.在 IntelliJ IDEA 的Code Style设置中,没有任何
.gradle
文件的子类别(例如build.gradle
),并且在Other File Types下,没有任何修改大括号位置的选项。 I did not find solutions on to set brace placement for .gradle
files.我没有找到为
.gradle
文件设置大括号位置的解决方案。
What I'm trying to do: Make the braces look like this by default and after reformatting:我正在尝试做的事情:默认情况下和重新格式化后使大括号看起来像这样:
repositories
{
mavenCentral()
}
Instead of this:而不是这个:
repositories {
mavenCentral()
}
Is this change possible using the current version of IntelliJ IDEA?使用当前版本的 IntelliJ IDEA 是否可以进行此更改? (2020.1.1)
(2020.1.1)
Changing the code style settings for Groovy does not have an effect for some reason.由于某种原因,更改 Groovy 的代码样式设置没有效果。
Braces for a Groovy class is placed correctly as in the settings. Groovy class 的大括号按照设置正确放置。 (This is tested in a
.gradle
file.) (这是在
.gradle
文件中测试的。)
It looks like the Settings (Preferences on macOS) → Editor → Code Style → Groovy → Wrapping and Braces → Braces placement → * Other option does not work as expected.看起来设置(macOS 上的首选项)→编辑器→代码样式→ Groovy →包装和大括号→大括号放置→ *其他选项无法按预期工作。
Please vote for the issue IDEA-241366 .请为IDEA-241366问题投票。
.gradle
files are actually Groovy files. .gradle
文件实际上是 Groovy 文件。 You can check that by looking under Editor → File Types → Groovy .您可以通过查看Editor → File Types → Groovy来检查。
As such, you can modify the code style for Groovy to move braces onto the next line by going under Editor → Code Style → Groovy → Wrapping and Braces tab → Braces placement and tweaking it to your liking.因此,您可以修改 Groovy 的代码样式以将大括号移动到下一行,方法是在编辑器→代码样式→ Groovy →包装和大括号选项卡 →大括号放置并根据自己的喜好进行调整。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.