如何在Intellij中格式化Java的C#样式之类的代码? [英] How to format code like C# style for Java in Intellij?
本文介绍了如何在Intellij中格式化Java的C#样式之类的代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Intellij进行Java开发,但是我更喜欢C#这样的编码风格.如何格式化像C#代码样式?例如:
I am using Intellij for Java development, but I prefer C# like coding style. How to format like C# code style? For example:
if()
{
/// do something
}
else
{
//// do something
}
推荐答案
转到
文件->设置->编辑器->代码样式-> Java
- 转到
Wrapping and Braces
标签.
在 - 处,有一个名为
Others
的下拉列表,将其更改为Next Line
. (默认为行尾).这将更改除类和方法声明以外的所有位置的括号位置. - 如果您还希望类和方法声明也以这种样式显示,请将
Braces placement
部分(In class declaration
,In method declaration
)中的两个以前的下拉菜单也更改为Next Line
.
Braces placement
下的- Go to
Wrapping and Braces
tab. - under
Braces placement
, there's a drop-down calledOthers
, change it toNext Line
. (by default it is End of line). This will change bracer placement for all the places other than class and method declaration. - If you want class and method declarations also to appear in that style, change 2 previous drop-downs in
Braces placement
section(In class declaration
,In method declaration
) toNext Line
also.
这篇关于如何在Intellij中格式化Java的C#样式之类的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文