Take the 2-minute tour ×  If I open files I created in Windows,
the lines all end with ^M. How do I delete them all in once?
share|improve this question add comment  16 Answers  up vote 257
down vote accepted  dos2unix is a commandline utility that will
do this, or :%s/^M//g will if you use ctrl-v ctrl-m to input the
^M, or you can :set ff=unix and vim will do it for you.  Docs on
the 'fileformat' setting are here, and the vim wiki has a
comprehensive page on line ending conversions.  Alternately, 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.
share|improve this answer That was it for me thank you pal :>
Bash wouldn't launch the script because of line endings. Stupid
notepad really... –  Gepsens Aug 9 '11 at 1:29 "set ff=unix" in
vi is simple and awesome –  user655489 Apr 1 '12 at 16:27 +1 for
set ff=unix. It's in my config now :) –  bitmask Jul 9 '13 at
9:31 :%s/^M//g should