18

The answer to this must be somewhere but I'm not finding it -- can anyone help me understand why in Gedit, if I have a page of code there is no extra trailing blank line, but then when I do a file comparison for my svn commit it shows an extra line being added at the end of the file?

I have a feeling that Gedit is automatically adding an ending line break. But why, I have no idea...

tishma
  • 1,855
  • 1
  • 21
  • 43
Sam
  • 1,246
  • 1
  • 19
  • 27

4 Answers4

24

Reality finally won and it's been fixed, but the broken behavior is still the default; enable the WYSIWYG behavior in a terminal with

gsettings set org.gnome.gedit.preferences.editor ensure-trailing-newline false
blargg
  • 356
  • 2
  • 3
  • Ugh, ensure-trailing-newline instead of hide-and-ensure-trailing-newline aaargh – Tachytaenius Aug 01 '21 at 18:41
  • In case you see the `dconf-WARNING **: 01:23:35.210: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)` error then (for `debian` and its friends) run the `apt install dbus-x11` command first – Teodor May 13 '22 at 22:27
  • ... also, looks like this solution doesn't work for ubuntu 22.04 – Teodor May 13 '22 at 23:05
6

It's a feature. I don't think it can easily be disabled.

this is intentional: text files should always be terminated by \n, otherwise tools like 'cat', 'sed' etc may have problems. However there is no reason to always show an empty line at the bottom of the text view, that's why we do not show the last \n

paolo borelli [gedit developer]

Mark Byers
  • 811,555
  • 193
  • 1,581
  • 1,452
  • 3
    Thanks. This is unfortunate because I wanted to use gedit but I need to be able to delete that line break in some cases... I wonder if that's possible. – Sam Jun 16 '10 at 20:24
  • I would like to see a small space at the bottom (even a single pixel) so I can more easily tell the difference between an underscore and a space. – Brad Pitcher Mar 07 '14 at 18:34
  • 3
    Feature or not, it's absolutely misleading and counter-intuitive to change file contents without making it visible to the user. – tishma Dec 15 '14 at 13:21
1

Some editors (I'm unfamiliar with Gedit specifically) will try to ensure that a file always ends with a newline character. Other editors, like perhaps the one that you originally created the file with, will allow you to end a file without a final newline character.

Greg Hewgill
  • 951,095
  • 183
  • 1,149
  • 1,285
1

Try the Whitespace Remover plugin.

pfrenssen
  • 5,498
  • 1
  • 22
  • 16