I am trying to remove the control characters from the middle of each line in a file. Here is my data below. I used the below command but it doesn’t seem to work.
Command:
:%s/^M//g
Data:
53,v42,p11,51097,310780,ok^M,fraud
56,v45,p11,260,1925,ok^M,fraud
68,v42,p11,51282,278770,ok^M,fraud
96,v49,p14,212,1545,ok^M,fraud
163,v50,p20,373819,1006375,ok^M,fraud
204,v50,p26,36917,117195,ok^M,fraud
241,v70,p33,21777,91360,ok^M,fraud
Output Warning:
E486: Pattern not found: ^M
Take a look at this post: http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/
The basic reasoning is that typing ^M searches for the literal interpretation, two characters of ^ and M where instead you want to construct the actual control character from your input.