Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
docs:vim:fileformats [2007/03/25 21:09] – created billhdocs:vim:fileformats [2009/06/24 17:39] (current) billh
Line 1: Line 1:
 +====== fileformats ======
 +  * http://www.vi-improved.org/wiki/index.php/FileFormat
  
 +===== Fixing Detection Problems =====
 +If your file has consistent line endings throughout, but you have had a 'ff' detection problem, the best fix is to force Vim to use the correct format with the :e command:
 +<code>
 +:e ++ff=mac
 +</code>
 +
 +If your file **does not** have consistent line endings throughout, you need to force vim to load it a certain way without any assumptions.  This example is where the output from a grep command was run and captured to a file.  Some of the results were from dos files, and others from unix files, so the line endings aren't consistent, and vim shows us ^M characters because it is interpreted as unix.
 +<code>
 +:set ffs=dos
 +:e ++ff=dos
 +</code>
 +In this case you should see vim list [CR missing] in the status line after loading the file.  Vim has fixed the line endings for you, so now you can simply do this to save the file and open it as a corrected dos file:
 +<code>
 +:w
 +:e!
 +</code>
 +
 +===== conversion =====
 +This will read a file (assuming "dos"), convert line-endings to unix (<CR><NL> pairs will be <NL>):
 +<code>
 +:e file
 +:set fileformat=unix
 +:w
 +</code>