To those who think the default behavior is a "deficiency" or a "bad
design decision": it is neither. It is the only correct behavior when
dealing with text files. It is not a matter of "simple" vs. "complex"
editors either: it is a matter of Windows vs. Unix text format.

In the Windows world, text files use CRLF as line _separators_. In the
Unix world, text files use LF (newline) as line _terminators_. This is
an important distinction, and it implies that a text file _must_ end
with a newline character. Otherwise it's not a valid text file. 

See "Why should text files end with a newline?":
https://stackoverflow.com/questions/729692

The argument about this causing problems with PHP is moot. PHP accepts
"?>\n" as a valid end-of-code delimiter: it doesn't output the final
"\n". Proof:

    $ echo '<?php echo "foo"; ?>' > foo.php
    $ hd foo.php        # Notice the final 0a = LF
    00000000  3c 3f 70 68 70 20 65 63  68 6f 20 22 66 6f 6f 22  |<?php echo 
"foo"|
    00000010  3b 20 3f 3e 0a                                    |; ?>.|
    00000015
    $ php foo.php | hd  # Notice the _lack_ of final LF
    00000000  66 6f 6f                                          |foo|
    00000003
    $ 

Note also that in vim you can save a file with no final newline, but for
this you have to enable "binary" mode, which makes sense because the
file you are saving is no longer a text file.

-- 
You received this bug notification because you are a member of Ubuntu
Desktop Bugs, which is subscribed to gedit in Ubuntu.
https://bugs.launchpad.net/bugs/379367

Title:
  Gedit adding a newline at the end of file should be configurable

To manage notifications about this bug go to:
https://bugs.launchpad.net/gedit/+bug/379367/+subscriptions

-- 
desktop-bugs mailing list
desktop-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/desktop-bugs

Reply via email to