Function: evil-change

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

Signature

(evil-change BEG END &optional TYPE REGISTER YANK-HANDLER DELETE-FUNC)

Documentation

Change text from BEG to END with TYPE.

Save in REGISTER or the kill-ring with YANK-HANDLER. DELETE-FUNC is a function for deleting text, default evil-delete. If TYPE is line, insertion starts on an empty line. If TYPE is block, the inserted text in inserted at each line of the block.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
(evil-define-operator evil-change
  (beg end type register yank-handler delete-func)
  "Change text from BEG to END with TYPE.
Save in REGISTER or the kill-ring with YANK-HANDLER.
DELETE-FUNC is a function for deleting text, default `evil-delete'.
If TYPE is `line', insertion starts on an empty line.
If TYPE is `block', the inserted text in inserted at each line
of the block."
  (interactive "<R><x><y>")
  (let ((delete-func (or delete-func #'evil-delete))
        (nlines (1+ (evil-count-lines beg end)))
        opoint leftmost-point)
    (save-excursion
      (goto-char beg)
      (setq opoint (line-beginning-position))
      (setq leftmost-point
            (let ((inhibit-field-text-motion t)) (line-beginning-position))))
    (unless (eq evil-want-fine-undo t)
      (evil-start-undo-step))
    (funcall delete-func beg end type register yank-handler)
    (cond
     ((eq type 'line)
      (setq this-command 'evil-change-whole-line) ; for evil-maybe-remove-spaces
      (cond
       ((/= opoint leftmost-point) (evil-insert 1)) ; deletion didn't delete line
       ((= opoint (point)) (evil-open-above 1))
       (t (evil-open-below 1))))
     ((eq type 'block)
      (evil-insert 1 nlines))
     (t (evil-insert 1)))
    (setq evil-this-register nil)))