Function: evil-visual-expand-region

evil-visual-expand-region is a byte-compiled function defined in evil-states.el.

Signature

(evil-visual-expand-region &optional EXCLUDE-NEWLINE)

Documentation

Expand the region to the Visual selection.

If EXCLUDE-NEWLINE is non-nil and the selection ends with a newline, exclude that newline from the region.

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-states.el
(defun evil-visual-expand-region (&optional exclude-newline)
  "Expand the region to the Visual selection.
If EXCLUDE-NEWLINE is non-nil and the selection ends with a newline,
exclude that newline from the region."
  (when (and (evil-visual-state-p)
             (not evil-visual-region-expanded))
    (let ((mark evil-visual-beginning)
          (point evil-visual-end))
      (when (< evil-visual-direction 0)
        (evil-swap mark point))
      (setq evil-visual-region-expanded t)
      (evil-visual-refresh mark point)
      (when (and exclude-newline
                 (save-excursion
                   (goto-char evil-visual-end)
                   (and (bolp) (not (bobp)))))
        (if (< evil-visual-direction 0)
            (evil-move-mark (max point (1- (mark))))
          (goto-char (max mark (1- (point)))))))))