This problem can be solve installing the google-java-format Plugin.
Open plugins window (CTRL+Shift+A): plugins
Click on browse repositories.
Search for google-java-format
Install the plugin.
Restart the IDE.
Enable the plugin executing the action (Ctrl+Shift+A): Reformat with google-java-format Update: in the newer version of the plugin select Reformat since the plugin overrides / enhances the functionality of the standard "Reformat" command.
Additional notes from the google-java-format README
Answer from Geekecom on Stack OverflowThe plugin will be disabled by default. To enable it in the current project, go to File→Settings...→google-java-format Settings (or IntelliJ IDEA→Preferences...→Other Settings→google-java-format Settings on macOS) and check the Enable google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for you.)
To enable it by default in new projects, use File→Other Settings→Default Settings....
This problem can be solve installing the google-java-format Plugin.
Open plugins window (CTRL+Shift+A): plugins
Click on browse repositories.
Search for google-java-format
Install the plugin.
Restart the IDE.
Enable the plugin executing the action (Ctrl+Shift+A): Reformat with google-java-format Update: in the newer version of the plugin select Reformat since the plugin overrides / enhances the functionality of the standard "Reformat" command.
Additional notes from the google-java-format README
The plugin will be disabled by default. To enable it in the current project, go to File→Settings...→google-java-format Settings (or IntelliJ IDEA→Preferences...→Other Settings→google-java-format Settings on macOS) and check the Enable google-java-format checkbox. (A notification will be presented when you first open a project offering to do this for you.)
To enable it by default in new projects, use File→Other Settings→Default Settings....
As mentioned Here, Download the intellij-java-google-style.xml file from the This Link.
Then in Intellij, go Under Settings -> Editor -> Code Style. there in Scheme settings (settings icon on right side) -> import schemes-> intellij idea code style xml. Select the xml downloaded in first step. then in Scheme dropdown select the GoogleStyle IDE (newly added style). Click on apply and close.
Codestyle and formatters
Guide: Reformat Java Code with Google Style Guide in IntelliJ IDE
Google -java-format Code formatter for java Intellij - Stack Overflow
How to run google format by execute google-java-format Plugin in Intellij IDEA - Stack Overflow
Hi y'all,
My team would like to standardise code formatting and enforce it in CI. We've tried google-java-formatter but it doesn't look nearly as good as inteliJ's default settings.
Ideally, we'd like to export inteliJs defaults (to have the benefits of built in formatter) and use something that would enforce it on CI build. Has anyone done it? What are your pipelines like? Any tips and tricks?
Quoting the github page:
Note: There is no configurability as to the formatter's algorithm for formatting. This is a deliberate design decision to unify our code formatting on a single format.
Either use google-java-formatter, or don't. (I simply stopped caring about GJF's choices years ago, because I'm used to it; and even in cases where it doesn't format it exactly how I'd like, the formatting is not totally disagreeable).
If I understand well, you want the IntelliJ to stop wrapping your lines ?
For that you can set the Hard Wrap field to a higher value. The default is 120, which means that every line of more than 120 characters will be wrapped.
You can find this parameter in Settings>Editor>Code Style (And not in Settings>Editor>Code Style>Java)