vlion: cut of the flammarion woodcut, colored (Default)
vlion ([personal profile] vlion) wrote in [community profile] emacs2011-12-16 09:27 pm

Dos2Unix conversion

Hello my fellow Emacs users!

This snippet should give you the abiility to remove those ^M characters you get from time to time if you do much emacs work relating to Windows systems. If the first argument in search-forward doesn't copy over right, it can be inserted with C-q C-m.

Have fun!


(defun remove-dos-line-endings () 
"Removes those pesky ^M from a buffer"
  (interactive)
  (save-excursion 
    (goto-char 0) 
    (while (search-forward " " nil t) 
             (replace-match "" nil t))))

jld: (vessel)

[personal profile] jld 2011-12-18 02:59 am (UTC)(link)
"\C-m" might be a nicer way to get that string into the script.
Edited 2011-12-18 03:00 (UTC)