Skip to content

Instantly share code, notes, and snippets.

@maw
Created December 7, 2015 18:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maw/2f30ba164824f3c4a5d9 to your computer and use it in GitHub Desktop.
Save maw/2f30ba164824f3c4a5d9 to your computer and use it in GitHub Desktop.
;; http://emacs.stackexchange.com/a/3174 via xtreak on freenode
(defun youngfrog/copy-rectangle-to-kill-ring (start end)
"Saves a rectangle to the normal kill ring. Not suitable for yank-rectangle."
(interactive "r")
(let ((lines (extract-rectangle start end)))
(with-temp-buffer
(while lines ;; insert-rectangle, but without the unneeded stuff
;; (most importantly no push-mark)
(insert-for-yank (car lines))
(insert "\n")
(setq lines (cdr lines)))
(kill-ring-save (point-min) (point-max)))))
(defun kill-rectangle-as-text (b e)
(interactive "r")
(progn (youngfrog/copy-rectangle-to-kill-ring b e)
(delete-rectangle b e)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment