Is it possible to remove empty/blank lines using code formatting in Intellij IDEA?
Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).
replaceAll() may be replacing a line at the end and leaving the line blank. Use str2. trim() or move str2 = str2. replaceAll("\\s","") after the second replaceAll() .
Yes. It is possible to configure the number of blank lines in the settings menu (CTRL+ATL+S): File -> Settings -> Editor -> Code Style -> Java(or Scala or whatever your language is) -> Blank Lines
File >> Setting >> Editor >> Code style java >>Blank lines tab
You should change to 0 in code label(as picture), It would remove all unnecessary blank line when press format shortcut: ctrl + alt + L
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With