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?

Mohammed Shirhaan
  • 555
  • 1
  • 11
  • 27
  • Please refer to [this question](https://stackoverflow.com/questions/1601793/how-do-i-modify-eclipse-code-formatting) – samabcde Apr 29 '19 at 05:28
  • @samabcde I did not find my need there. I am looking for code to make Autowired in the same line as object declaration. – Mohammed Shirhaan Apr 29 '19 at 06: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. – samabcde Apr 29 '19 at 06:14
  • @samabcde right I want same line for Autowire annotation only. That is what I am not able to find. – Mohammed Shirhaan Apr 29 '19 at 06:43

0 Answers0