Function: evil-ex-join

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

Signature

(evil-ex-join BEG END &optional COUNT BANG)

Documentation

Join the selected lines with optional COUNT and BANG.

Key Bindings

Source Code

;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
(evil-define-operator evil-ex-join (beg end &optional count bang)
  "Join the selected lines with optional COUNT and BANG."
  (interactive "<r><a><!>")
  (let ((join-fn (if bang 'evil-join-whitespace 'evil-join)))
    (if (not count)
        ;; without count - just join the given region
        (funcall join-fn beg end)
      (unless (string-match-p "^[1-9][0-9]*$" count)
        (user-error "Invalid count"))
      ;; emulate Vim's :join when count is given - start from the
      ;; end of the region and join COUNT lines from there
      (save-excursion
        (goto-char end)
        (let ((beg-adjusted (line-beginning-position 0))
              (end-adjusted (line-beginning-position (string-to-number count))))
          (funcall join-fn beg-adjusted end-adjusted))))))