Function: kill-visual-line

kill-visual-line is an interactive and byte-compiled function defined in simple.el.gz.

Signature

(kill-visual-line &optional ARG)

Documentation

Kill the rest of the visual line.

With prefix argument ARG, kill that many visual lines from point. If ARG is negative, kill visual lines backward. If ARG is zero, kill the text before point on the current visual line.

If the variable kill-whole-line(var)/kill-whole-line(fun) is non-nil, and this command is invoked at start of a line that ends in a newline, kill the newline as well.

If you want to append the killed line to the last killed text, use C-M-w (append-next-kill) before C-k (kill-line).

If the buffer is read-only, Emacs will beep and refrain from deleting the line, but put the line in the kill ring anyway. This means that you can use this command to copy text from a read-only buffer.
(If the variable kill-read-only-ok is non-nil, then this won't
even beep.)

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun kill-visual-line (&optional arg)
  "Kill the rest of the visual line.
With prefix argument ARG, kill that many visual lines from point.
If ARG is negative, kill visual lines backward.
If ARG is zero, kill the text before point on the current visual
line.

If the variable `kill-whole-line' is non-nil, and this command is
invoked at start of a line that ends in a newline, kill the newline
as well.

If you want to append the killed line to the last killed text,
use \\[append-next-kill] before \\[kill-line].

If the buffer is read-only, Emacs will beep and refrain from deleting
the line, but put the line in the kill ring anyway.  This means that
you can use this command to copy text from a read-only buffer.
\(If the variable `kill-read-only-ok' is non-nil, then this won't
even beep.)"
  (interactive "P")
  ;; Like in `kill-line', it's better to move point to the other end
  ;; of the kill before killing.
  (let ((opoint (point))
        (kill-whole-line (and kill-whole-line (bolp)))
        (orig-vlnum (cdr (nth 6 (posn-at-point)))))
    (if arg
	(vertical-motion (prefix-numeric-value arg))
      (end-of-visual-line 1)
      (if (= (point) opoint)
	  (vertical-motion 1)
        ;; The first condition below verifies we are still on the same
        ;; screen line, i.e. that the line isn't continued, and that
        ;; end-of-visual-line didn't overshoot due to complications
        ;; like display or overlay strings, intangible text, etc.:
        ;; otherwise, we don't want to kill a character that's
        ;; unrelated to the place where the visual line wraps.
        (and (numberp (cdr (nth 6 (posn-at-point))))
             (= (cdr (nth 6 (posn-at-point))) orig-vlnum)
             ;; Make sure we delete the character where the line wraps
             ;; under visual-line-mode, be it whitespace or a
             ;; character whose category set permits wrapping at it.
             (or (looking-at-p "[ \t]")
                 (and word-wrap-by-category
                      (aref (char-category-set (following-char)) ?\|)))
             (forward-char))))
    (kill-region opoint (if (and kill-whole-line (= (following-char) ?\n))
			    (1+ (point))
			  (point)))))