UNIX treats the end of line differently than other operating systems. Sometimes when editing files in both Windows and UNIX environments, a CTRL-M character is visibly displayed at the end of each line as ^M in vi.
To remove the ^M characters at the end of all lines in vi, use:
:%s/^V^M//g