Closed vi closed 12 years ago
I checked vim behavior - it is the same, as enki. And I would prefer to leave as is. If you want to have \n after last line - you can do it easily. If you don't want to have it - you also can do it easily.
But after starting using Enki I noticed that such files started appearing which was not the case in Vim...
Example session: $ vim /tmp/q i12345Esc;wq $ enki /tmp/w 12345 Alt+F4; save checked $ diff -ur /tmp/{q,w} ... -12345 +12345 \ No newline at end of file
Maybe missing EOL at end of file should be highlighted somehow + Enki should automatically add a new line at the end if user types in the last empty line (user may explicitly delete it if he wants).
Nano, ed and gedit also creates a EOL-terminated files by default. (but not Emacs unfortunately)
Hmm. I checked vim once more. If file is empty (0 bytes) - vim lefts it as is. But for not empty files it appends EOL.
Done. Will see if functionality is useful.
Forgot to push to github. Will be available later.
clarification: Vim saves 0-byte file if file was saved just after creation. But if any edit operation was done - EOL is added. So even absolutely empty file saved as one EOL symbol. Enki now always adds EOL to any text. So, it is impossible to generate 0-byte file with Enki
I have remarked this also. I would like to have this option to create a new line at the end. Now i create it at every time manually when i realise that is missing in diff checks before committing...
@hlamer: could be reviewed to add it even as a non default option?
I don't quite understand how many new lines are necessary. Enki always adds 1 EOL when saving, and strips back when loading. If you see asdf
on the screen, Enki saves
a@a-desktop ~/tmp $ od -tx1 test.txt
0000000 61 73 64 66 0a
If there is a new line at the end of the file and the file is edited and saved in enki, the new line at the end is removed and diffs show the message: "\ No newline at end of file" There is also a pylint message "W292 no newline at the end of file"
If you create new file, type just x
and save the file, what is the file size on the file system?
1 byte
I cannot reproduce it with git version and python3 it saves a 2 bytes file, ok with the new line. I switch definitely to python3 and git version
Hmm. Very interesting problem, since for me and the others py2 also works fine. But let's focus on stabilization py3 version.
\n is a line terminator, not separator.
Text should end with \n by default.
Enki should create files ending in "\n" easily (and files without trailing \n less easy, i.e. by opening existing
No newline at end of file
file).