Function: evil-copy-chars-from-line
evil-copy-chars-from-line is an interactive and byte-compiled function
defined in evil-commands.el.
Signature
(evil-copy-chars-from-line N NUM &optional COL)
Documentation
Return N characters from line NUM, starting at column COL.
NUM is relative to the current line and can be negative. COL defaults to the current column.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/evil-20251108.138/evil-commands.el
;; adapted from `copy-from-above-command' in misc.el
(defun evil-copy-chars-from-line (n num &optional col)
"Return N characters from line NUM, starting at column COL.
NUM is relative to the current line and can be negative.
COL defaults to the current column."
(interactive "p")
(let ((col (or col (current-column))) prefix)
(save-excursion
(forward-line num)
(when (looking-at "[[:space:]]*$")
(if (< num 0)
(skip-chars-backward " \t\n")
(skip-chars-forward " \t\n")))
(evil-move-beginning-of-line)
(move-to-column col)
;; if the column winds up in middle of a tab,
;; return the appropriate number of spaces
(when (< col (current-column))
(if (eq (preceding-char) ?\t)
(let ((len (min n (- (current-column) col))))
(setq prefix (make-string len ?\s)
n (- n len)))
;; if in middle of a control char, return the whole char
(backward-char 1)))
(concat prefix
(buffer-substring (point)
(min (line-end-position)
(+ n (point))))))))