How to remove unnecessary blank line on code forma

2019-01-21 09:01发布

Is it possible to remove empty/blank lines using code formatting in Intellij IDEA?

4条回答
放我归山
2楼-- · 2019-01-21 09:28

You can find and replace with regex option also ^(?:[\t ]*(?:\r?\n|\r))+. It searches all empty lines in file. You need to just replace it with empty

查看更多
该账号已被封号
3楼-- · 2019-01-21 09:35
  • 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

enter image description here

查看更多
forever°为你锁心
4楼-- · 2019-01-21 09:43

Just in case it helps someone using newer versions of Intellij, in Intellij IDEA 2016.2.4 it is File -> Other Settings -> Default Settings -> Editor -> Code Style -> Java(or Scala or whatever your language is) -> Blank Lines

查看更多
相关推荐>>
5楼-- · 2019-01-21 09:47

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

Blank lines configuration

查看更多
登录 后发表回答