.editorconfig and IntelliJ -> Reformat Code

59 views Asked by At

I'm currently working on configuring our code editor settings to adhere to best practices and enhance our coding consistency. I am considering using the .editorconfig file for this purpose.

# Sample generated with IntelliJ
# and https://github.com/hjhgitw/oshi/blob/master/.editorconfig
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true # delete whitespace at the end of each line

#did try (not exactly knowing what to set)
[*.java]
ij_java_class_count_to_use_import_on_demand = 1000 # Do not group imports with an asterisk
ij_java_names_count_to_use_import_on_demand = 1000 # Do not group imports with an asterisk
ij_java_align_multiline_annotation_parameters = false
ij_java_annotation_parameter_wrap = off
ij_java_class_annotation_wrap = split_into_lines
ij_java_do_not_wrap_after_single_annotation = false
ij_java_do_not_wrap_after_single_annotation_in_parameter = false
ij_java_new_line_after_lparen_in_annotation = false
ij_java_rparen_on_new_line_in_annotation = false
ij_java_variable_annotation_wrap = off

Sample @Inject with no newline in Java:

    @Inject PlaceManager placeManager;

Should not be converted to:

    @Inject
    PlaceManager placeManager;

Could someone please point me in the right direction with .editorconfig (or if not possible with IntelliJ setting)?

1

There are 1 answers

0
Hansjörg Hofer On

did now find the solution..

In IDEA it's controlled by “Settings → Editor → Code Style → Java → Wrapping and Braces tab → Field annotations” option.

In EditorConfig it should be controlled by “ij_java_field_annotation_wrap” option.

THX to Support

https://intellij-support.jetbrains.com/hc/en-us/community/posts/16454308467986--editorconfig-and-IntelliJ-Reformat-Code?page=1#community_comment_16686595126674