Intellij Idea code formatting/auto formatting on save

Since the previous project used google style, the method of using google style is also introduced here.

1. Install google-java-format
preferences -> plugins -> Browse repositories...
search for google-java-format
write picture description here

enable google-java-format
write picture description here

2. Install save actions
preferences -> plugins -> Browse repositories...
Search save actions to
write picture description here
enable
automatic formatting when
save Delete useless import statements
write picture description here

3. Automatically optimize the package options
write picture description here

4. Check Line Separator/Indent Size

Line separators need to be uniform, windows must not be used
write picture description here

Indent size needs to be uniform
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326490334&siteId=291194637