Friday, August 20, 2010

Conversion Between
DOS, Unix, and Mac Text Files

 
Vim is a real champ when it comes to
converting from one text file format
to another. Historically, the big
3 text ile formats have been:

  • DOS
  • Mac
  • Unix

Here's the corresponding commands
you can use to do conversions to
the above formats:

  • :set ff=dos
  • :set ff=mac
  • :set ff=unix

Alternatively, you can spell
everything out with the following
commands:

  • :set fileformat=dos
  • :set fileformat=mac
  • :set fileformat=unix

When Vim reads the file into
its buffer, it determines the
format. To query what Vim has
determined, use the following
command:

:set ff

Alternatively, you can spell your
query out with:

:set fileformat

That's all it takes to do a text
file conversion in Vim.

Well, not quite all. Of course
you have to save the file to make
the conversion complete. Here's
one way to save the file:

ZZ

Here's another way to save the file:

:wq

Ed Abbott