Friday, June 15, 2007

Tip: Simple fileformat (dos/unix) conversion with VIM

Sometimes, someone drops you a text file with windows newlines, and you need it converted for your unix. There are oneliners to do it in sed, awk, perl, tr, ... but they always seems to have slipped my mind, when I need them.

Here is a simple way to do it with vim:
  • vim file
  • :set fileformat=unix
  • :wq
Done!

1 comment:

Hubert said...

Simpler way is to lauch dos2unix or unix2dos program if you have those on your system. You don't even have to specify different output file, dos2unix will use intermediate file.