Monday, October 26, 2009

Change file format (Dos/Unix) in Vim

Unix and dos (Windows) use different file format. Even though the latest Vim can detect the file format automatically, sometimes you also need to convert your file to the other format, especially if you are sharing the file with your friends.

Fortunately, in vim you can set the file format using a very simple command.

Change the file format to dos

:set ff=dos

Change the file format to unix

:set ff=unix


You can also add those commands in .vimrc file to make Vim starts with the desired format of file.