Function: cua-string-rectangle

cua-string-rectangle is an interactive and byte-compiled function defined in cua-rect.el.gz.

Signature

(cua-string-rectangle STRING)

Documentation

Replace CUA rectangle contents with STRING on each line.

The length of STRING need not be the same as the rectangle width.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/emulation/cua-rect.el.gz
(defun cua-string-rectangle (string)
  "Replace CUA rectangle contents with STRING on each line.
The length of STRING need not be the same as the rectangle width."
  (interactive "sString rectangle: ")
  (cua--rectangle-operation 'keep nil t t nil
     (lambda (s e l _r)
        (delete-region s e)
        (skip-chars-forward " \t")
        (let ((ws (- (current-column) l)))
          (delete-region s (point))
          (insert string)
          (indent-to (+ (current-column) ws))))
     (unless (cua--rectangle-restriction)
       (lambda (l _r)
          (cua--rectangle-right (max l (+ l (length string) -1)))))))