.editorconfig and IntelliJ -> Reformat Code

已回答

Source thread : https://stackoverflow.com/questions/77830883/editorconfig-and-intellij-reformat-code

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`](https://editorconfig.org/) file for this purpose.

```lang-toml 
# 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)?

0

Hello,

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.

0

Thanks a lot, both worked! 


ij_java_field_annotation_wrap = off

 

& Happy Coding

0

You are welcome!

0

请先登录再写评论。