Version: SVN (using KDE 4.5.2) OS: Linux I would like to have a configuration option so that every files I save ends with a newline on every line, including the last line. It has been considered a good practice in the Unix/Linux world that every lines end with a newline character. Some editors like Vi don't even propose a choice about this. Reproducible: Didn't try Steps to Reproduce: 1. Open Kwrite 2. Types: Line 1<ENTER>Line 2 3. Save the file as "demo.txt" Actual Results: $ od -a demo.txt 0000000 L i n e sp 1 nl L i n e sp 2 0000015 $ wc -l demo.txt 1 demo.txt Opening the file with vi, it warns that the current file has no EOL: "demo.txt" [noeol] 2L, 13C Expected Results: $ od -a demo.txt 0000000 L i n e sp 1 nl L i n e sp 2 nl 0000016 $ wc -l demo.txt 2 demo.txt Saving the file with Vi will add the missing newline character. Reopening it with Kwrite and showing line numbers, the content is displayed with 3 lines: 1| Line 1 2| Line 2 3| It looks like a unique newline at the end of a file is interpreted by Kwrite as an empty line.
I'd love to have that feature, it would be easy to implement but helps a lot. Any takers? I'd help with the implementation, otherwise I'll probably hack it in over the weekend.
*** Bug 134852 has been marked as a duplicate of this bug. ***
Hi Milian, any news about this? I would be glad to contribute myself but haven't enough competencies :(
This is implemented in KDE 4.9. In the Open/Save config dialog, there is now an option called [ ] Append newline at end of file on save By default, it is off. You can also use a modeline called newline-at-eof: bool [default: false] either in the document itself, or in the .kateconfig file, or in the "Modes & Filetypes" config tab. If remove-trailing-spaces-on-save is enabled and the last line only contains spaces, no newline is appended.
Thank you for fixing this. I also see KDevelop (4.4.1, KDE 4.9.5) exposes the same settings for its embedded KatePart.