On Friday, November 16, 2012 10:11:34 AM UTC-6, Salman Halim wrote:
> 
> Occasionally, I will get a file that was edited by both developers on DOS and 
> Unix systems and their editors will quietly leave mixed newlines in there. I 
> believe that Vim will open a file with mixed newlines as Unix (at least, this 
> is what I see). 
> 
> 
> Basically, this counts the number of ^M characters and prints a message 
> reporting the number of ^M characters (if any) and, if more than half the 
> file contains them, suggests that the file might be DOS--otherwise, Unix. It 
> also returns Vim script commands to fix the file format, but the autocommand 
> doesn't use that. I put an arbitrary line limit of 10,000 lines so that the 
> file opening process isn't slowed down too much by this check.
> 
> 
> Admittedly, it's going to be have to refactored for Mac; also, that 'silent! 
> execute' line contains a ^M (literal control-M) where there's a newline in 
> the paste below.
> 

Here's a script to do the automatic reload for you (between DOS and Unix still 
unfortunately):

http://vim.wikia.com/wiki/Automatically_reload_files_with_mixed_line-endings_in_DOS_fileformat

This version uses a timeout in milliseconds on a search() rather than limiting 
by number of lines.

-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Reply via email to