我正在尝试删除文件中每行中间的控制字符。下面是我的数据。我使用了下面的命令,但它似乎不起作用。
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
发布于 2012-11-23 02:46:54
看看这篇文章:http://www.tech-recipes.com/rx/150/remove-m-characters-at-end-of-lines-in-vi/
To remove the ^M characters at the end of all lines in vi, use:
:%s/^V^M//g
The ^v is a CONTROL-V character and ^m is a CONTROL-M. When you type this, it will look like this:
:%s/^M//g
基本的推理是键入^M搜索文字解释,即^和M这两个字符,而您希望从输入中构造实际的控制字符。
发布于 2013-07-12 15:30:56
是的,按住“Ctrl”键和“v”键,然后按住“Ctrl”键和“m”键,而不是直接键入“^v”和“^m”。
发布于 2015-08-31 16:07:07
如何使用VI编辑器从unix文件中删除^M使用此命令。
:%s(Ctrl+V)(Ctrl+M)/
重要!!-按(Ctrl-v) (Ctrl- M )组合键输入^M字符,不要使用“^”和M。
https://stackoverflow.com/questions/13518481
复制相似问题