如何在Intellij中格式化Java的C#样式之类的代码? [英] How to format code like C# style for Java in Intellij?

查看:141
本文介绍了如何在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标签.
  • Braces placement下的
  • 处,有一个名为Others的下拉列表,将其更改为Next Line. (默认为行尾).这将更改除类和方法声明以外的所有位置的括号位置.
  • 如果您还希望类和方法声明也以这种样式显示,请将Braces placement部分(In class declarationIn method declaration)中的两个以前的下拉菜单也更改为Next Line.
  • Go to Wrapping and Braces tab.
  • under Braces placement, there's a drop-down called Others, change it to Next 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) to Next Line also.

这篇关于如何在Intellij中格式化Java的C#样式之类的代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆