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 Desktop
Packages, 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

Status in gedit:
  Fix Released
Status in gedit package in Ubuntu:
  Invalid

Bug description:
  Binary package hint: gedit

  Ggedit auto adds a newline at the end of file.I hope it can be
  configurable.

  I'm not a c/c++ developer, i'm php developer. but I use gedit for my
  php developing. Gedit auto adds a new line at the end of file, which
  will cause a problem when the program runs. I hope this action can be
  configurable. thanks~!

  ProblemType: Bug
  Architecture: i386
  DistroRelease: Ubuntu 8.10
  ExecutablePath: /usr/bin/gedit
  Package: gedit 2.24.2-0ubuntu1
  ProcEnviron:
   PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
   LANG=zh_CN.UTF-8
   SHELL=/bin/bash
  SourcePackage: gedit
  Uname: Linux 2.6.27-14-generic i686

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

-- 
Mailing list: https://launchpad.net/~desktop-packages
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~desktop-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to