[ACCEPTED]-Eclipse and curly braces-eclipse
Yes, edit your active profile (Java...Code 4 Style...Formatter), and change the brace 3 positions to the next line. Also, in Java..Editor..Typing, you 2 can have it automatically insert your braces 1 at the correct position.
For pre-written block of code, first do 5 the settings as suggested by Don and then 4 select that piece of code and right click 3 Source Code->Format and the formatting would 2 take place as per the settings done in the 1 preferences.
Current versions of eclipse have a more 7 convenient way of doing this.
Go to Preferences->Java->Code 6 Style->Formatter
Click on edit, and on the 5 new opened window, go to the Braces tab. Here 4 you can choose how different types of blocks 3 of code organize their curly braces.
Hope 2 this helps any who google this, and find 1 this post. (Like myself)
Regards to all!
Coming from C# background I couldn't come 6 to grips with built in Java formatting of 5 Eclipse.
With some effort I managed to get 4 most of what Visual Studio used to offer 3 me. Here is an XML version of it. You can import the file..
Preferences->Java->Code 2 Style->Formatter->Import->Apply
Additionally 1 see arguments on which approach is better on our sister site..
The simplest and global way:
Go to Window 4 -> Preferences.
Then in search put: "brace".
Select 3 -> Java -> Code Style-> Formatter After 2 opening new window go to brace tab and change 1 it as you prefer.
In addition to the methods of changing the 12 settings and ctrl-shift-f to apply, these 11 settings can be done on a per project basis. Simply 10 right-click on your project, choose properties, Java 9 Code Style, and enable the checkbox for 8 "enable project specific settings."
I find 7 this invaluable for use between projects 6 I work on to configure it to match a particular 5 client style, along with other settings 4 to try to match code formatting of existing 3 code. This way, you won't upset other people 2 but can still use your own style on other 1 code bases. :)
More Related questions
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.