Emacs: Copy Rectangle Region to kill-ring

By Xah Lee. Date: . Last updated: .

When you Alt+x kill-rectangle, the text does not go into emacs kill-ring nor the OS's clipboard.

[see Emacs: Edit Column Text, Rectangle Commands]

Here a command to copy rectangle region to emacs's kill-ring.

(defun xah-copy-rectangle-to-kill-ring (@begin @end)
  "Copy region as column (rectangle region) to `kill-ring'
See also: `kill-rectangle', `copy-to-register'.
URL `http://ergoemacs.org/emacs/emacs_copy_rectangle_text_to_clipboard.html'
version 2016-07-17"
  ;; extract-rectangle suggested by YoungFrog, 2012-07-25
  (interactive "r")
  (require 'rect)
  (kill-new (mapconcat 'identity (extract-rectangle @begin @end) "\n")))

Rectangle Edit Topic

  1. Emacs: Edit Column Text, Rectangle Commands
  2. Emacs: Insert Alphabets A to Z
  3. Emacs: Copy Rectangle Region to kill-ring
  4. Emacs: Align Text
  5. Emacs: picture-mode, ASCII Diagram
  6. Emacs: Make Whitespaces Visible

Copy/Paste Topic

  1. Emacs: Copy/Paste and kill-ring History
  2. Emacs: Copy/Cut Current Line If No Selection
  3. Emacs: Copy/Cut All or Selection
  4. Emacs: Paste or Paste Previous
  5. Emacs: Show kill-ring
  6. Emacs: Copy to Register
  7. Emacs: 1 Key to Copy/Paste from Register
  8. Emacs: Copy Append
  9. Emacs: Copy Rectangle Region to kill-ring
  10. Emacs: Sync Copy/Paste Clipboards with Linux X11
Like my tutorial? Put $5 at patreon

Or Buy Xah Emacs Tutorial

Or buy a nice keyboard: Best Keyboard for Emacs