A blog dedicated to text editing and general exploration of computing knowledge
Another way::set ff=unix:wThis will convert DOS text format into Unix text format.
Strangely, replacing a literal line break with another literal line break (ctrl-V enter) gets rid of them too::%s/^M/^M/g
For me;:set ff=unix does not work. I use the following..function! CleanScript() :%s/^M//g :%s/^[//g :%s/\[K//g :%s/^H//gendfwhere ^M and the rest are entered via ctrl-v ctrl-m
Entering <C-v><C-m> is the same as using \r.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.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.
I find that this works a little better, at least for me:%s/^M\+$//Which will get rid of carriage returns, of one or more in a row, at the end of the line.This keeps it from removing the ^M in cases where you actually wanted it there, like the old style vi control-char mappings.Cheers.
or u can use dos2unix#dos2unix src.txt dest.txt
Post a Comment