You will occasionally have to deal with conversion of a DOS file which appears in Vim with a ˆM character at the end of each line. The simplest way to do so is to simply search for and replace them, as follows: %s/control-m//g. That is, to search for a ˆM you search for control-M. You can just as easily search for carriage returns (r) like this: %s/r//g. If you're using Vim on a Windows machine, the opposite may occur, and you'll find ˆJ characters at the line ends and beginnings of a Unix file. Treat it the same way, searching and replacing.
Both phenomena are caused by Vim failing to identify a text file as one format or another (usually because both types of line endings are present). The fileformat command is how you declare your intention; the next time you save the file the appropriate line endings will be used, and when you reopen it the strange characters should disappear. For example :set ff=unix.