This post goes over how to convert a file from DOS to UNIX using Vim:
DOS to UNIX
To convert file.txt
from DOS to UNIX, open the file with Vim:
vim file.txt
Set fileformat
to unix
:
:set fileformat=unix
Save and quit the file:
:wq
This is the same as running the command:
vim '+set ff=unix' '+x' file.txt
UNIX to DOS
To convert file.txt
from UNIX to DOS, open the file with Vim:
vim file.txt
Set fileformat
to dos
and write and quit the file:
:set fileformat=dos
Save and quit the file:
:wq
This is the same as running the command:
vim '+set ff=dos' '+x' file.txt
Replace ^M
To replace ^M
, run a global string replace in Vim:
:%s/^M//g
^M
is entered by typing Ctrl
+ v
and Ctrl
+ m
.