简体   繁体   中英

customize organize import in eclipse

I am using organize import in eclipse and this is one of the best features of eclipse.

But can i customize organize import the way i want to.

Ex.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

But I want it to be something like this.

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

}

It organizes opening brace in same line as function. But I want it to be at the next line.

Can I customize to have this opening bracket in next line ? So whenever I do organize import it automatically changes to opening bracket in the next line.

Thanks in advance.

You do this with the Source > Format command ( Ctrl + Shift + F , on a Mac this is Cmd + Shift + F ).

How the code is formatted is set in Preferences > Java > Code Style > Formatter . Edit an existing profile or create a new one and look at the Braces section.

You can set formatting to be done automatically when you save a file in Preferences > Java > Editor > Save Actions .

I guess you mean "format code" instead of organize import.

You can achieve what you want easily:

click on

window > preferences 

and then

Java > Code Style > Formatter

Eclipse has base formatters that you cannot modify. However you can copy them and modify them to create your own based on the default eclipse included ones.

You need to create yours and then edit it.

under the tab "braces" you'll find what you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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