I used gedit on a source code file, and it doesn't appear to distinguish whether or not the file ends in a newline or not. Both cases show up the same in the editor. Reproducible: Always Steps to Reproduce: 1. Create a file with no newline at the end 2. Load it with gedit, take a look at the bottom of the editing area 3. Save without doing any edits (should logically not change it, but a terminating newline gets pasted on the end)
This is a deliberate design decision by gedit's creators - see https://bugzilla.gnome.org/show_bug.cgi?id=625955 By default, a last newline is always added because gedit's creators assume that's what you usually want (and for C-like languages and common config files, it probably is what most users usually want). If you are editing php code or some other file type where last newlines are undesirable, you can change gedit's behavior using 2 methods: * gui: open dconf-editor, disable org → gnome → gedit → preferences → editor → ensure-trailing-newline * command line: gsettings set org.gnome.gedit.preferences.editor ensure-trailing-newline false If you think this option should easier to find, or that the default behavior should be different - please tell that to gedit upstream developers.
I checked upstream and they already got chewed out by quite a few users. They stubbornly refused to back down. Easy workaround so closing.