Skip to content

Instantly share code, notes, and snippets.

@Frozenlock
Created July 31, 2012 13:26
Show Gist options
  • Save Frozenlock/3217025 to your computer and use it in GitHub Desktop.
Save Frozenlock/3217025 to your computer and use it in GitHub Desktop.
(defun replace-string-in-rectangle (from-string to-string &optional delimited start end)
(interactive
(let ((common
(query-replace-read-args
"Replace string in rectangle" nil)))
(list (nth 0 common) (nth 1 common) (nth 2 common)
(region-beginning)
(region-end))))
(let ((replacement-rectangle
(mapcar '(lambda (arg) (replace-in-string arg from-string to-string))
(extract-rectangle start end))))
(delete-rectangle start end)
(goto-char start)
(insert-rectangle replacement-rectangle)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment