Eclipse and braces

Is there a quick way to force Eclipse to insert curly braces on the next line (separately) on a block of code?

+44
java eclipse
Aug 6 '09 at 1:21
source share
6 answers

For a pre-written block of code, first make the settings suggested by the don, and then select this code fragment and right-click the source code-> Format and formatting will be performed in accordance with the settings made in the settings.

+29
Aug 6 '09 at 4:13
source share

Yes, edit your active profile (Java ... Code Style ... Formatter) and change the position of the brackets to the next line. In addition, in Java..Editor..Typing you can automatically insert your curly braces in the correct position.

+54
Aug 6 '09 at 1:35
source share

Existing versions of eclipse have a more convenient way to do this.

Go to Settings-> Java-> Code Style-> Formatting

Click "Edit", and in the new window that opens, go to the "Bracelets" tab. Here you can choose how various types of code blocks arrange curly braces.

Hope this helps anyone who did this and find this post. (As I)

For all!

+27
Mar 22 2018-11-11T00:
source share

Coming from a C # background, I couldn't handle the Java Eclipse native formatting.

With some effort, I managed to get most of what Visual Studio offered me. Here is the XML version . You can import the file.

Settings-> Java-> Code Style-> Formatting-> Import-> Apply

Additionally, see the arguments for the best approach on our partner site.

+3
Jan 14 '13 at 23:30
source share

The easiest and most global way: Go to the window β†’ Settings. Then in the search, put: "bracket". enter image description here

Choose -> Java -> Code Style -> Formatter. After opening a new window, go to the bracket tab and change it as you prefer.

+3
Apr 13 '13 at
source share

In addition to the methods for changing settings and ctrl-shift-f to apply, these settings can be made for each project. Just right-click on your project, select properties, Java Code style and check the box "Enable specific project settings."

I find it invaluable for use between the projects I'm working on, for setting it up according to a specific type of client along with other settings, in order to try to combine code formatting of existing code. This way you won’t upset other people, but you can still use your own style on other code bases. :)

+2
Aug 07 '09 at 20:29
source share



All Articles