If you open files that were created in Windows and the lines all end with ^M, you can delete them with one of the following approaches:

  • dos2unix is a command line utility that will convert DOS line endings to Unix line endings
  • In Vim, you can run :%s/^M//g, but you must type Ctrl-v Ctrl-m to input the ^M.
  • You can also run :set ff=unix to make Vim do this automatically.

Alternatively, if you move files back and forth a lot, you might not want to convert them, but rather to do :set ff=dos, so Vim will know it’s a DOS file and use DOS conventions for line endings.



Tags: instructions