Function: evil-ex-put

evil-ex-put is an interactive and byte-compiled function defined in evil-commands.el.

Signature

(evil-ex-put BEG END EX-ARG &optional FORCE)

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
(evil-define-command evil-ex-put (_beg end ex-arg &optional force)
  (interactive "<r><a><!>")
  (let* ((arg-chars (remove ?\s (string-to-list ex-arg)))
         (reg (or (car arg-chars) ?\"))
         (text (cond
                ((and (< 1 (length arg-chars))
                      (/= ?= reg))
                 (user-error "Trailing characters"))
                ((eq ?= reg)
                 (evil--eval-expr (if (= 1 (length arg-chars))
                                      evil-last-=-register-input
                                    (setq evil-last-=-register-input (substring ex-arg 1)))))
                (t (evil-get-register reg)))))
    (unless text (user-error "Nothing in register %c" reg))
    (evil-remove-yank-excluded-properties text)
    (goto-char (if (= (point-max) end) end (1- end)))
    (if force (evil-insert-newline-above) (evil-insert-newline-below))
    (evil-set-marker ?\[ (point))
    ;; `insert' rather than `insert-for-yank' as we want to ignore yank-handlers...
    (insert (if (and (< 0 (length text))
                     (eq ?\n (aref text (1- (length text)))))
                (substring text 0 (1- (length text)))
              text))
    (evil-set-marker ?\] (1- (point)))
    (back-to-indentation)
    (evil-normal-state)))