tag:blogger.com,1999:blog-6637736252081011583.post1507509348044191356..comments2023-10-23T11:13:47.199-07:00Comments on Daily Vim: Text Editor Tips, Tricks, Tutorials, and HOWTOs: Removing Ctrl-MTravis Whittonhttp://www.blogger.com/profile/14592647486468034166noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-6637736252081011583.post-25327448538009523042011-12-20T03:54:25.264-08:002011-12-20T03:54:25.264-08:00or u can use dos2unix
#dos2unix src.txt dest.txtor u can use dos2unix<br /><br />#dos2unix src.txt dest.txtAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-34010781592833224952009-01-24T14:41:00.000-08:002009-01-24T14:41:00.000-08:00I find that this works a little better, at least f...I find that this works a little better, at least for me:<BR/><BR/>%s/^M\+$//<BR/><BR/>Which will get rid of carriage returns, of one or more in a row, at the end of the line.<BR/><BR/>This keeps it from removing the ^M in cases where you actually wanted it there, like the old style vi control-char mappings.<BR/><BR/>Cheers.Doug Pottshttps://www.blogger.com/profile/02515536168736550460noreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-89728171251394095782009-01-09T07:51:00.000-08:002009-01-09T07:51:00.000-08:00Entering <C-v><C-m> is the same as usi...Entering <C-v><C-m> is the same as using \r.<BR/><BR/>Replacing all \r's with \r actually changes the document is in :h sub-replace-special. Vim uses carriage returns internally to store a file's newlines regardless of the setting for 'fileformat' (which only matters at read/write). Actual newlines, \n, are used to represent NULs.<BR/><BR/>And changing 'ff' after the file is loaded only changes what is written for EOL when the file is saved. It will never remove those ^M's.graywhhttps://www.blogger.com/profile/14008240961525657558noreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-68634699183956515802009-01-08T13:29:00.000-08:002009-01-08T13:29:00.000-08:00For me;:set ff=unix does not work. I use the foll...For me;<BR/><BR/>:set ff=unix <BR/><BR/>does not work. I use the following..<BR/><BR/>function! CleanScript()<BR/> :%s/^M//g<BR/> :%s/^[//g<BR/> :%s/\[K//g<BR/> :%s/^H//g<BR/>endf<BR/><BR/>where ^M and the rest are entered via ctrl-v ctrl-mChrishttps://www.blogger.com/profile/08053614400760550597noreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-2743734920712540582009-01-08T10:01:00.000-08:002009-01-08T10:01:00.000-08:00Strangely, replacing a literal line break with ano...Strangely, replacing a literal line break with another literal line break (ctrl-V enter) gets rid of them too:<BR/><BR/>:%s/^M/^M/gGreg Whitescarverhttps://www.blogger.com/profile/09235651080908874850noreply@blogger.comtag:blogger.com,1999:blog-6637736252081011583.post-91502754700811470372009-01-08T09:27:00.000-08:002009-01-08T09:27:00.000-08:00Another way::set ff=unix:wThis will convert DOS te...Another way:<BR/><BR/>:set ff=unix<BR/>:w<BR/><BR/>This will convert DOS text format into Unix text format.Anonymousnoreply@blogger.com