• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 145
  • Last Modified:

how to do custom format in java using eclipse

Hi,

as of now eclipse default format and indentation option giving as below

if (a < 1) {
			System.out.println("aa");
		}

		else {
			System.out.println("false");
		}
		

Open in new window

           
            i want as below so that i can see inner if and related inner else etc in big chain of if loops

            
if (a < 1) {
			System.out.println("aa");
		}else {
			System.out.println("false");
		}

Open in new window

           

how to achieve this.

In one of my example with if loop i get error like below

Syntax error on token(s), misplaced construct(s)

How to fix this.

How to create custom source code formatting in eclipse.

please advise
0
gudii9
Asked:
gudii9
  • 2
1 Solution
 
Mark BullockQA Engineer IIICommented:
In Preferences or Settings:
Expand Java / Code Style, then click Formatter.
Click Edit...
Click Control Statements

Then you can format your code as you like it.

Before you can save your change, you'll have to change the Profile name.
0
 
gudii9Author Commented:
I created new profile how to apply that profile for newly created class. How to apply new format for newly created all classes, projects in that workspace. please advise
0
 
Mark BullockQA Engineer IIICommented:
Open the .java file you want to format.
Select all of the text.
Right-click and select Source / Format
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now