1

i've created an empty txt-file as a template for other (very new and clueless) unix-users, to make sure they don't forget the txt-extension and use the correct newline & encoding when exchanging simple texts/notes with windows-users/machines.

now an interesting problem occurs:

  • files created on top of this empty template are messed up under windows (of corse because of the lacking CR).
  • a template with just a space (or any other text) in it works as it should but just if created with pluma/xed (based on gedit), gedit itself or vim; but when created with leafpad or mousepad it behaves like the empty templates.
  • at the point when there is a newline in the template it works with every of the mentioned editors.

is there a way to create an empty txt-file with saved settings like encoding and newline/EOL?

bonus-question: why do this editors save different files?


to make some things clear: i understand the different newline-styles for text-files and for sure all files are encoded in UTF-8.

  • I wonder how many editors would care about the vim header comment block. – phk Feb 10 '17 at 21:35
  • @phk: i test also vim and it's files also behaves like them from gedit. - added this also to the question... – DJCrashdummy Feb 10 '17 at 22:38
  • 1
    The answer to the bonus question is that editors are trying to be compatible with both Unix and Windows, and not mess up files that you edit. So if the file starts with Windows-style newlines, the editor saves with that format. If it starts with Unix newlines, the editor saves with that format. And if it starts with no newlines, the editor uses its default format. – Barmar Feb 10 '17 at 23:01
2

Instead of creating an empty file, put some comments in it that tell the user how to fill it in. This will be helpful to the users, and should also solve the problem that the editor doesn't know the proper newline style to use.

  • well... for sure that was the workaround i used, but is not really a answer to my question. :-/ – DJCrashdummy Feb 11 '17 at 15:11
  • 1
    It may be the best you can do. AFAIK, there's no file attribute that tells applications what newline style to use, all they can do is infer it from the existing contents. – Barmar Feb 11 '17 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.