2012-06-29

Emacs Commpand to Copy Rectangle to Clipboard

Here's a command to copy a column of text to clipboard.

(defun copy-rectangle-to-clipboard (p1 p2)
  "Copy region as column (rectangle) to operating system's clipboard.
This command will also put the text in register 0. (see: `copy-to-register')"
  (interactive "r")
  (let ((x-select-enable-clipboard t))
    (copy-rectangle-to-register ?0 p1 p2)
    (kill-new
     (with-temp-buffer
       (insert-register ?0)
       (buffer-string) )) ) )

See also: Emacs: Manipulate Column Text, string-rectangle, ASCII-Art