Remove Carriage Return (^M) Characters with Emacs

I was editing some code which was originally written on a Windows machine and it had carriage return characters at the end of each line:

Screenshot of Emacs editing a file with trailing carriage returns on each line

To remove them:

M-x replace-string RET C-q C-m RET RET

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s