Vi Search And Repalce With ^M

The following shows the command used in 'vi' to search and replace:

%s/old/new/g

Typically, (in sed at least) in case one of the two 'old' or 'new' strings contains a / , you can replace it with most any other character instead. Whatever comes after the 's' will be used as a seperator.

:%s/^M//g

The above will substitute the '^M' with an empty string, where '^M' is input as a control character by using <ctrl>v <ctrl>m.

The g is for all instances on the line, the % is to the end of the file (these may be redundant because sed is in the habit of using the g for global since it works one line at a time).