简体   繁体   English

如何在Intellij中格式化Java的C#风格的代码?

[英]How to format code like C# style for Java in Intellij?

I am using Intellij for Java development, but I prefer C# like coding style. 我正在使用Intellij进行Java开发,但是我更喜欢C#这样的编码风格。 How to format like C# code style? 如何格式化像C#代码样式? For example: 例如:

     if()
     {
          /// do something
     }
     else
     {
        //// do something
     }

Go to

File -> Settings -> Editor -> Code Style -> Java 文件->设置->编辑器->代码样式-> Java

在此处输入图片说明

  • Go to Wrapping and Braces tab. 转到Wrapping and Braces选项卡。
  • under Braces placement , there's a drop-down called Others , change it to Next Line . Braces placement ,有一个名为Others的下拉菜单,将其更改为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. 如果您还希望类和方法声明也以该样式显示,则还将Braces placement部分( In class declarationIn method declaration )的两个以前的下拉菜单也更改为Next Line

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM