helix icon indicating copy to clipboard operation
helix copied to clipboard

Toggle to enforce a newline at the end of a document

Open vdccc opened this issue 3 years ago • 1 comments

I suggest adding a toggle eol to enforce a newline at the end of a document.

vdccc avatar Oct 14 '22 15:10 vdccc

I wonder if editorconfig can help enforce it? #279

kuanyinglu avatar Oct 14 '22 16:10 kuanyinglu

It might be worth mentioning that this is also already unconditionally enforced by rustfmt (:fmt?). So if #279 is implemented/merged, we'd have at least 2 features which enforce this, and this new option would be a third one...

usagi-flow avatar Mar 31 '23 15:03 usagi-flow

this new option would be a third one

I think that there are quite a few cases where such option would provide value, being any where rustfmt or editorconfig isn't available/applicable/redundant.

An example would be editing a simple text file, or a simple script whete I don't want to add an entire editorconfig.

tosti007 avatar Mar 31 '23 16:03 tosti007

Yes. It would also nice to have a config setting that specifies whether helix should insert a newline at end of file if none exists whenever saving a file (regardless of which language the file is in).

And another config setting to always remove trailing whitespace on save.

Sublime Text has both config settings.

Boscop avatar Apr 17 '23 10:04 Boscop

Found this because I have the same predicament. Never had the issue in vim, and vscode comes with a config file.insertFinalNewline because they also don't do it by default.

SuperFluffy avatar May 05 '23 16:05 SuperFluffy

I think this would be a great addition as well. It looks like there was a pull request linked above that seemed almost ready to merge that has since been closed. Any way that could be reopened to continue the work?

djpowers avatar May 27 '23 20:05 djpowers

As it was closed, it's probably better for someone to open a new pr to continue the work. Unless the original author comes back and wants to finish it, but in the meantime it should be ok for someone else to pick it up.

gabydd avatar May 27 '23 20:05 gabydd

I think having a .editorconfig in the /home/user directory would be the better or more generic approach.

dvc94ch avatar Jun 02 '23 14:06 dvc94ch