GNOME Bugzilla – Bug 445895
Gedit messes CRLF files, using LF line endings
Last modified: 2009-01-10 17:15:22 UTC
Please describe the problem: When Gedit change files with CRLF line endings, like TXT Windows/MS-DOS files, new lines inserted have LF file endings, instead of original format, causing problems for people using Windows. $ file /mnt/fileserver/text.txt text.txt: ASCII text, with CRLF line terminators $ gedit /mnt/fileserver/text.txt $ file /mnt/fileserver/text.txt text.txt: ASCII text, with CRLF, LF line terminators Steps to reproduce: 1. I open TXT (plain text - CRLF end-of-line) files, created by co-workers using Windows, located in our Netware file server (access by ncpfs mount point). 2. I insert new lines into the files (notes or updated informations). 3. I save them. Actual results: 1. After some time one or more persons complain about messed text files. 2. I tell them that was my fault. 25 Windows against 1 Linux user, me. :-) 3. I have to open a shell session and run unix2dos manually on files at our server share. Before, the "file" command showed "CRLF, LF" format for them, instead of "CRLF". Expected results: Gedit should insert new lines using the same end-of-line format of original file. Does this happen every time? Yes Other information:
Created attachment 109361 [details] Screenshot from Mousepad showing solution to problem Bug confirmed. Propsoed solution: do the same thing that XFCE's Mousepad does (see screenshot). That is, provide a little box in the 'save' dialogue next to the "Character encoding" box that lets you select between CR, LF, and CR+LF. Default to whatever format the text file was in originally. For new files, obviously default to LF. Whichever option is selected, use that for all line endings. Not only would that avoid mixed format, but it would allow people to more easily swap files between Windows and Linux boxes without gaving to use unix2dos or dos2unix converters all the time. For added user-friendlyness, call the options "Linux format (LF, Recommended)", "Windows format (CRLF)", and "Mac OS Classic format (CR)".
A somewhat similar use case is described in this Debian bug: "gedit can open CRLF and LF files and display them identically. however, copying text from one to the other retains the line endings of the original, even when the file is saved. i suggest that upon pasting, gedit automatically converts the line endings to that of the rest of the document. i also suggest this behaviour be triggered, when the file is saved too." See http://bugs.debian.org/480411
Thanks for the bug report. This particular bug has already been reported into our bug tracking system, but please feel free to report any further bugs you find. *** This bug has been marked as a duplicate of 347231 ***