Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. How to format like C# code style? For example:

     if()
     {
          /// do something
     }
     else
     {
        //// do something
     }
like image 440
bios Avatar asked Dec 28 '25 07:12

bios


1 Answers

Go to

File -> Settings -> Editor -> Code Style -> Java

enter image description here

  • 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.
like image 155
Supun Wijerathne Avatar answered Dec 30 '25 21:12

Supun Wijerathne