vi -- 删除替换linux下面文本中(^M)符号

来源:互联网 发布:两矩阵正交有什么性质 编辑:程序博客网 时间:2024/05/16 01:24

在linux下面编辑文本中会经常看见vi打开的文本中会有很多(^M)符号,其实这是dos下的换行符,如何才能去掉这些符号呢。除了可以借助外部工具如dos2unix,tr,sed,awk之外,vi本身也提供一些解决方案:

 

方案一:

 

:set ff=unix //to unix file
:set ff=dos //to windows file

 

方案二:

 

vim +"set ff=unix" +wq $DOS_FILE

 

方案三:

:%s/<Ctrl-V><Ctrl-M>//g

 

参考:

 

http://sources.redhat.com/ml/cygwin/2001-09/msg01754.html

 

http://74.125.155.132/search?q=cache:jN_w86M_M0AJ:anothersysadmin.wordpress.com/2007/11/30/deleting-dos-chars-using-vim-m/+vim+^m&cd=1&hl=en&ct=clnk

 

http://www.neuro.gatech.edu/users/cwilson/cygutils/V1.1/misc/index.html%22

 

 

原创粉丝点击