Maximum blank lines at EOF
Answered
Hi, sorry if this is obvious, but can't seem to figure it out.
I have enable the option of adding a blank line on save to the files. This works fine, but it doesn't seem to clean up any extra blank lines and therefore ensuring that there is only 1 blank line.
If I for some reason gets multiple blank lines in the end of a file, I would like for intellij to remove these and replace then with a single blank line.
Option that I'm looking for would be something like:
"Keep Maximum blank lines" -> After class
Is this possible?
Please sign in to leave a comment.
Hi. There is an option Keep maximum Blank lines in code at Code Style | Java | Blank lines.
It seems that the maximum number of lines are only applied inside the code statements and not at end of file (which is properly considered out of the code). If Intellij doesn't support removing all lines at the end of the file, do you know of any plugins that can do this?
I saw this:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/207227835-Trailing-space
And checked "Allow Placement of Caret after end of line" as suggested, but that doesn't help
Hi, Brian.
Could you please clarify the problem, do you already have more than one empty line at EOF, or does IDEA keep adding them on every reformat?
Sure :) The problem is that sometimes I end up with 2-3 linebreaks after the last line of code. Usually it's due to having copy-pasted something into the file, for reference and then deleting it or something like that.
Currently intellij will add an empty line at the end of the file if there isn't one (it doesn't continue to add lines, it will only add 1 which is correct). The problem arrises when (for any reason) I end up with 2-3 new lines. In that case I would like for intellj to remove all but 1.
The reason why it's an issue is that eclipse will make sure that there's only a single line at the end, and when I am using intellij and my colleagues are using eclipse, the cleanup tasks will cleanup files that wasn't changed.
We have an open feature request, please upvote: https://youtrack.jetbrains.com/issue/IDEA-119281