>From within vi: :1,$ s'^M''g To put ^M in the command line: Hold down on the CTRL key and press v and m. To accomplish the same task from the command line without opening the file: vi -c "%s/^M//g" -c "wq" file_name For multiple files: for f in /path/to/files/*; do vi -c "%s/^M//g" -c "wq" $f; done