Hello,
IF you want to delete dos chars using Vim instead of installing external tools like dos2unix,tr,sed,awk etc.. you can do that using Vim syntax like this:
:set ff=unix //to unix file
:set ff=dos //to windows file
See you!
UPDATE
If you want to do mass conversions, you can use this command lines switches and let vim do the work :)
vim +"set ff=unix" +wq $DOS_FILE
Sweet! This is far simpler than my method. Thanks :D
Not sure if it’s the version of vim i’m using, but this doesn’t work for me. I still have the ^M char at the end of lines. I’ve just been using :%s/.$// to remove the ^M
Matt, you must be shure that all lines end if ^M otherwise it will remove something that you won’t.
Using wg method you won’t have this problem.
Cheers.
This solution will not work. See http://vim.wikia.com/wiki/File_format
Bob, why do you say that? It works indeed
$ echo “123 check” > test.txt
$ file test.txt
test.txt: ASCII text
$ vim +”set ff=dos” +wq test.txt
$ file test.txt
test.txt: ASCII text, with CRLF line terminators
$ vim +”set ff=unix” +wq test.txt
$ file test.txt
Hi Bob,
Works fine here:
$ echo “hello” > test.txt
$ file test.txt
test.txt: ASCII text
$ cat -v test.txt
hello
$ vim +”set ff=dos” +wq test.txt
$ file test.txt
test.txt: ASCII text, with CRLF line terminators
$ cat -v test.txt
hello^M
$ vim +”set ff=unix” +wq test.txt
$ file test.txt
test.txt: ASCII text
$ cat -v test.txt
hello
What is your ouput error?