Replace ^m character
Use VI to view some of the text files created under Windows under Linux, sometimes finding "^m" at the end of a line. There are several ways to handle this.
1. Use the Dos2unix command. This gadget is available in the general distribution version (if it is not available to download according to the connection below), it is easy to use:
$ Dos2unix MyFile.txt
The above command will remove the ^m at the end of the line.
2. Use VI to replace the function. Start VI, enter command mode, and enter the following command:
:%s/^m$//g # Remove the ^m from the end of the line.
:%s/^m//g # get rid of all ^m.
:%s/^m/[ctrl-v]+[enter]/g # Replaces ^m with a carriage return.
:%s/^m/\r/g # Replaces ^m with a carriage return.
3. Use sed command. Similar to VI usage:
$ Sed-e ' s/^m/\n/g ' myfile.txt
Note: the "^m" here will be generated using "Ctrl-v ctrl-m" instead of typing "^m" directly.
Turn from: http://hi.baidu.com/mofeis/blog/item/23c7b2fb92dc97234e4aea6d.html
In Vim's _VIMRC file, remove Fileformat=unix.