Created
December 1, 2009 17:22
-
-
Save offby1/246451 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun replace-in-matching-lines (sought-re old-re new) | |
(interactive "sMatch lines containing:\nsOld regexp:\nsReplacement:") | |
(while (re-search-forward sought-re (point-max) t) | |
(save-restriction | |
(narrow-to-region (line-beginning-position) | |
(line-end-position)) | |
(goto-char (point-min)) ;i.e., beginning of line | |
(while (re-search-forward old-re (point-max) | |
t) | |
(replace-match new))) | |
(goto-char (line-end-position)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment