Remove carriage returns ^M
To remove carriage returns (
\r), often seen as^Mat the end of lines in files from Windows,:%s/^M//g
- How to type: ^M:
You cannot simply type a caret and an “^M”.
You must enter the literal control character by pressing:
Ctrl + VthenCtrl + M- Ctrl + V then return
- Note for Windows users: If you are using vi on Windows, use
Ctrl + QthenCtrl + M.Modern Vim alternative:
In many versions of Vim, you can simply use\r<code>:%s/\r//g
Clear entire file:
Shift+ H then Shift + V then Shift G then dd
