[TxMt] Re: TM (1.5.10) - auto translation of CR to LF on save?

Steve King sking at arbor.net
Fri Jan 6 20:03:12 UTC 2012


On 2012-01-06 13:15, Eric Hall wrote:
> 	We've discovered (naturally in an unpleasant way)
> that TM (1.5.10) will translate CR (0x0d) in a file to
> LF (0x0a) on save - even when the Line Endings setting
> "Use for existing files as well" is not checked.
> This seems like a bug, as it seems the settings are to
> leave existing files alone with respect to potential
> line ending characters.
> 	Is this a known issue?

I don't see that behavior here.  To demonstrate, I create a short file 
with CR terminators. Dump with 'od' to see that the terminators are 
plain CRs.

     macduff:/tmp$ od -a foo.txt
     0000000    f   o   o  cr   b   a   r  cr
     0000010

Edit and save that file in TextMate.  Dump again.  Terminators are still CR.

     macduff:/tmp$ od -a foo.txt
     0000000    l   o   r   e   m  cr   f   o   o  cr   b   a   r  cr   
i   p
     0000020    s   u   m  cr
     0000024

I can change the file to LF or CRLF terminators, but only if I 
explicitly tell TextMate to do so in the "Save As..." dialog.

     macduff:/tmp$ od -a foo.txt
     0000000    l   o   r   e   m  cr  nl   f   o   o  cr  nl   b   a   
r  cr
     0000020   nl   i   p   s   u   m
     0000026

Is it possible that your original file started with mixed line endings? 
In that case I think TM will either save the file with your default line 
ending rather than trying to preserve the inconsistencies.  Here's a 
file with mixed line endings; first CRLF, then CR, then LF.

     macduff:/tmp$ od -a foo.txt
     0000000    l   o   r   e   m  cr  nl   f   o   o  cr   b   a   r  
nl   i
     0000020    p   s   u   m
     0000024

Edit it in TextMate to add one line and save.  Now line endings are all LF.

     macduff:/tmp$ od -a foo.txt
     0000000    l   o   r   e   m  nl   f   o   o  nl   b   a   r  nl   
i   p
     0000020    s   u   m  nl   d   o   l   o   r
     0000031

-- 
Steve King
Sr. Software Engineer
Arbor Networks
+1 734 821 1461
www.arbornetworks.com <http://www.arbornetworks.com/>




More information about the textmate mailing list