Newline at end of file


This is just me asking a question in public and doing as little research on the subject as possible, but why wouldn’t you want a newline character at the end of a file?

There are several reasons why I can see they are more beneficial to have than not, I’ll list those out now:

  • Diffs display better on files that end in newlines
  • When I press “Ctrl + End” or “Cmd + Down” I don’t expect the file to scroll right (if the line is long enough)

So maybe bullet points weren’t necessary there because I only had two points, but it’s always been a pet-peeve of mine and I’m curious if there’s ever a good reason not to have one at the end.

Sure, the newline can go away in minified files, but I shouldn’t really care about diffs and actually editing them in an editor, so that doesn’t really count. I would consider that a deployment version, not a development version. I’m just referring to files that are shared in source control.

Super Simple Versioning of Third Party Scripts