If I open files I created in Windows, the lines all end with ^M.
How do I delete these characters all at once?
If I open files I created in Windows, the lines all end with ^M
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
dos2unix is a commandline utility that will do this.
In Vim,
:%s/^M//gwill if you use Ctrl–v Ctrl–m to input the ^M (On Windows, use Ctrl–q Ctrl-m instead).Vim may not show the
^Mcharacters if the file is loaded with ados(Windows) file format. In this case you can:set ff=unixand then save the file with:wor:w!and Vim will reformat the file as it saves it for you.There is documentation on the fileformat setting, 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.