Gedit adds line at end of file

2019-03-18 10:47发布

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...

4条回答
祖国的老花朵
2楼-- · 2019-03-18 11:25

Try the Whitespace Remover plugin.

查看更多
男人必须洒脱
3楼-- · 2019-03-18 11:30

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
查看更多
Root(大扎)
4楼-- · 2019-03-18 11:30

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.

查看更多
贪生不怕死
5楼-- · 2019-03-18 11:34

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]

查看更多
登录 后发表回答