-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to force a newline at the end of the file? #349
Comments
Thanks for asking. There is not, at present, any way to ensure that a file ends with a newline. It would not be hard to ensure that it did. Interestingly, it was kind of hard to generate a file that didn't end with a newline to test this out. I could imagine something like Your second request is, I think, to ensure that there is at most one blank line at any point, and not two or more. But to not add a blank line where one does not exist today. What I am not clear on is whether or not this is just at the "top level" of the file, that is the level at which I could see implementing something which would do what you desire regarding blank lines, though the implementation would be very different based on your answer to the above question. There have not been any requests for either of these capabilities prior to this, which is why they don't exist. My editor won't create a file that doesn't end in a newline, and I don't personally use |
Almost, but I must not have been clear -- I'm looking to have files that end with exactly one newline, so if there is no newline, add one, if there are multiple newlines remove all but one. Otherwise I wouldn't want this to impact any other whitespace setting and only impact just the end of the file (or well, if for some reason the file ended with a bunch of spaces and newlines ideally I'd strip all the trailing whitespace then add a single newline). Although even just "add a newline if there are none and otherwise do nothing" would still be useful if that's easier to implement.
Mine wont either 🙂. This came up in a work setting because we're using a few different editors and at least one of them seems to not add a final newline by default, so we keep ending up with spurious diffs on the last line depending on who edited the file last. |
Hi, thanks for a great tool!
I'm wondering if there's a way to ensure that files end with a newline, while using
{:style :respect-nl}
. Ideally I'd love to be able to configure zprint to trim all trailing newlines except one and add a trailing newline if it's missing. Based on #100 it looks like I might be able to get this behavior if I use{:parse {:interpose "\n\n"}}
but ideally I'd like to not change spacing between forms, just at the end of the file.I couldn't find this in the docs or in other issues, but sorry if I'm missing something totally obvious. Thanks!
The text was updated successfully, but these errors were encountered: