help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: replace-string limitation?


From: Rafael Sepúlveda
Subject: Re: replace-string limitation?
Date: 05 Oct 2000 23:08:45 -0500
User-agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7

pohl <pohl@screaming.org> writes:

> I'm familiar with the replace-string trick used to clean DOS
> carriage returns, but I'm curious about doing something slightly
> different: replacing some string with a unix newline.
> 
> For example, imagine that I'd like to replace all instances
> of <BR> with an actual newline character.  How would I do this?

I use this functions to convert text files between dos and unix and
viceversa. Maybe you can use them and modify them to meet your needs:

(defun dos2unix ()
 "Convert a buffer from MS-DOS ^M end of lines to UNIX end of lines."
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\r" nil t) (replace-match "")))
(defun unix2dos ()
  "Convert a buffer from UNIX end of lines to MS-DOS ^M end of lines."
  (interactive)
    (goto-char (point-min))
      (while (search-forward "\n" nil t) (replace-match "\r\n")))


-- 
Rafael Sepúlveda <rsepulveda@linuxmty.org>
http://www.linuxmty.org/people/rsepulveda

1024D/1981FDE7 F13B C41C 739B 7233 F738  D68E 2947 D868 1981 FDE7



reply via email to

[Prev in Thread] Current Thread [Next in Thread]