本文介绍了Intellij Formatter将方法级别注释和方法签名保持在一行中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IDE中尝试了几种格式化程序设置,但我无法实现以下功能:

I have tried several formatter settings in the IDE but I am not able to achieve following:

@Test
public void testMethod(){
..............
}

IntelliJ不断将代码更改为:

IntelliJ keeps changing above code to:

@Test public void testMethod(){
..............
}

有没有人能够解决这个问题?

Has anyone been able to figure this out?

推荐答案

转到设置,然后转到

编辑 - > 代码风格 - > Java

然后切换到标签环绕和支撑

节点重新格式化时保留,复选框换行符

go to Settings and then go to
Editor --> Code Style --> Java ,
then switch to tab Wrapping and Braces ,
node Keep when reformatting , checkbox Line breaks .

切换此复选框 on

同时查看方法注释

这屏幕截图取自版本2018.1,但在您的版本中看起来应该类似。

This screenshot is taken from Version 2018.1, but it should look similar in your version.

这篇关于Intellij Formatter将方法级别注释和方法签名保持在一行中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 16:23