GitHub Editor and not new line in Jupyter notebooks
Today I was working in a very simple Pull Request: Rename a command, in this case the old `ml-engine` vs `ai-platform`.
https://github.com/kubeflow/pipelines/pull/3260/commits/ec7528002c700d0fa00ee582c991400834bba2d8
I decided to use GitHub File Editor, as change was very simple.
Originally in Jupyter Notebook file, there is not newline, but File Editor adds the newline to file, which is the standard. A little bit of history:
According to POSIX, every text file should end with a \n
, or “newline” character. This acts as the eol
, or the “end of line” character. It is a line “terminator”.
3.206 Line A sequence of zero or more non- <newline> characters plus a terminating <newline> character.
This is the output for the changes, as you can see, I just renamed the commands but the original file does not have a newline, GitHub Editor just add it.
Nowadays the newline at EOF for text files may not be a requirement, but it is a useful convention that makes most Unix tools work together with consistent results.
If you want to remove the new line using vim to bring back as it was before, (Not as POSIX recommends) you can do it in 3 simple steps:
- Visualize new lines and carrier returns, open file using
vim
editor
:set list
in Vim will show whitespace. End of lines show as '$
' and carriage returns usually show as '^M
'.
2. The following command removes the final new line when the file is saved
:set noendoline binary
:wq
3. Commit the changes back into your repo.