How do I make IntelliJ IDEA insert a new line at every end of file, so that GitHub doesn't complain for example?
324
votes
8 Answers
497
votes
47
votes
31
votes
Possible alternative with a number of handy features is EditorConfig
Just submit an .editorconfig
file to your repo
[*]
insert_final_newline = true
And it will work natively not only in Idea, but in all major IDEs (some require a plugin).
Now all team members would have same configuration, eol, eof, and no more tabs vs spaces :)
14
votes
3
votes
2
votes
As Rider (IDEA's cousin for .NET) is driving me crazy, this might be helpful for those writing C# as Ensure line feed at file end on Save
alone won't work. It needs
File → Settings → Editor → Code Style → C# → Line Breaks and Wrapping → Line feed at end of file
.
I don't remember changing it and I haven't imported any settings for sure, so I guess it's by default disabled.