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

  • Comcast cable & Internet down in Winchendon MA, 3rd time this week. Gives one pause re: switching to their phone service. #fb 3 years 51 weeks ago
  • I just became the mayor of Beals Memorial Library on @foursquare! http://4sq.com/bpXyNX 4 years 1 day ago
  • I just became the mayor of Winchendon Field Office on @foursquare! http://4sq.com/aUMCCT 4 years 4 days ago
  • Hay baled fresh off the field -- we live in an awesome place. http://flic.kr/p/8hZF6t 4 years 5 days ago
  • Just picking up hay, honestly! (@ Murdock Dairy Farm) http://4sq.com/b9yjcJ 4 years 5 days ago

Older

Contact

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