Replace ^M (\r) Characters in Emacs

Despite my diligent efforts to create and edit files exclusively in UNIX mode with Emacs, once in a while I will open a document and find it peppered with the annoying ^M characters that represent carriage returns (as opposed to linefeeds.)

Copying the ^M character and attempting to yank it into the query-replace minibuffer doesn't work. Enter a convenient key combo to represent the escape char, C-q C-m. (The equivalent key combo for linefeeds is C-q C-j)

So to replace all CR characters with LF characters from the cursor to the end of the buffer, do like so:

M-%
Query replace: C-q C-m with: C-q C-j

Syndicate content

Twitter

  • RT@nadavoid: Drush can update drupal core. http://drupal.org/node/434944 Props to @weitzman, greg.1.anderson, and many others who helped. 4 years 25 weeks ago
  • Groovy bundle for TextMate: http://groovy.codehaus.org/TextMate 4 years 26 weeks ago
  • New post: Linoleum Block Printing http://tinyurl.com/ybt243y #fb 4 years 26 weeks ago
  • It's going to take all my will not to sleep all day again 4 years 26 weeks ago
  • Racist angry loudmouth racist rural Massachusetts republican is racist. And loudmouthed. 4 years 27 weeks ago

Older

Contact

Andy Chase
(978) 297-6402
andychase [at] gmail.com
GPG/PGP Public Key