1

I want to add an additional formatter in eclipse to format @Autowired annotation in the same line as the Object declaration when I format (Ctrl+Shift+F).

If it is currently,

@Autowired
TestService testService;

After pressing Ctrl+Shift+F I want it to be as

@Autowired TestService testService;

The Code formatter xml file is already existing in my project. But I am not sure how they have added each of the formatter in it. Following are 2 of the many other formatters.

<setting value="end_of_line" id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration"/>

<setting value="do not insert" id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case"/>

How to write additional value in this file for my need?

4
  • Please refer to this question Commented Apr 29, 2019 at 5:28
  • @samabcde I did not find my need there. I am looking for code to make Autowired in the same line as object declaration. Commented Apr 29, 2019 at 6:06
  • If you want all annotation of field keep in the same line, you can go to editing formatter page-> New Lines tab-> Annotations section ->uncheck "Insert new line after annotations on fields". If you only want same line for Autowire annotation only, I think you need to do some more research as eclipse does not provide such configuration. Commented Apr 29, 2019 at 6:14
  • @samabcde right I want same line for Autowire annotation only. That is what I am not able to find. Commented Apr 29, 2019 at 6:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.