Convert Dos File to Linux Format Wit Vim

Thu 03 December 2009 Category: Uncategorized

If you have some file that has been saved on a (Win)do(w)s host you may notice that all lines end with ^M.

To fix this, you can use the tool dos2unix. If however this tool is not at your disposal, you may have a problem. If vim is available, you do not have a problem:

The trick is to delete all occurances of ^M with this line:

:%s/ctrl-v ctrl-m//g

This will look like:


Just save the file and you're done.