The eternal fight between admins and computers


Deleting dos chars using Vim (^M)

Posted in Oneliner, Tips, Unix, Windows by rga on November 30, 2007

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

2 Responses to 'Deleting dos chars using Vim (^M)'

Subscribe to comments with RSS or TrackBack to 'Deleting dos chars using Vim (^M)'.

  1. wg said,

    Sweet! This is far simpler than my method. Thanks :D

  2. Matt Cook said,

    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


Leave a Reply