Function: visual-line-mode
visual-line-mode is an interactive and byte-compiled function defined
in simple.el.gz.
Signature
(visual-line-mode &optional ARG)
Documentation
Toggle visual line based editing (Visual Line mode) in the current buffer.
When Visual Line mode is enabled, word-wrap is turned on in
this buffer, and simple editing commands are redefined to act on
visual lines, not logical lines. See Info node (emacs)Visual Line
Mode for details.
Turning on this mode disables line truncation set up by
variables truncate-lines and truncate-partial-width-windows.
This is a minor mode. If called interactively, toggle the
Visual-Line mode mode. If the prefix argument is positive,
enable the mode, and if it is zero or negative, disable the mode.
If called from Lisp, toggle the mode if ARG is toggle. Enable
the mode if ARG is nil, omitted, or is a positive number.
Disable the mode if ARG is a negative number.
To check whether the minor mode is enabled in the current buffer,
evaluate visual-line-mode(var)/visual-line-mode(fun).
The mode's hook is called both when the mode is enabled and when it is disabled.
C-a beginning-of-visual-line
C-e end-of-visual-line
C-k kill-visual-line
Probably introduced at or before Emacs version 24.4.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(define-minor-mode visual-line-mode
"Toggle visual line based editing (Visual Line mode) in the current buffer.
When Visual Line mode is enabled, `word-wrap' is turned on in
this buffer, and simple editing commands are redefined to act on
visual lines, not logical lines. See Info node `Visual Line
Mode' for details.
Turning on this mode disables line truncation set up by
variables `truncate-lines' and `truncate-partial-width-windows'."
:keymap visual-line-mode-map
:group 'visual-line
:lighter " Wrap"
(if visual-line-mode
(progn
(unless visual-line--saved-state
(setq-local visual-line--saved-state (list nil))
;; Save the local values of some variables, to be restored if
;; visual-line-mode is turned off.
(dolist (var '(line-move-visual truncate-lines
truncate-partial-width-windows
word-wrap fringe-indicator-alist))
(if (local-variable-p var)
(push (cons var (symbol-value var))
visual-line--saved-state))))
(setq-local line-move-visual t)
(setq-local truncate-partial-width-windows nil)
(setq truncate-lines nil
word-wrap t
fringe-indicator-alist
(cons (cons 'continuation visual-line-fringe-indicators)
fringe-indicator-alist)))
(kill-local-variable 'line-move-visual)
(kill-local-variable 'word-wrap)
(kill-local-variable 'truncate-lines)
(kill-local-variable 'truncate-partial-width-windows)
(kill-local-variable 'fringe-indicator-alist)
(dolist (saved visual-line--saved-state)
(when (car saved)
(set (make-local-variable (car saved)) (cdr saved))))
(kill-local-variable 'visual-line--saved-state)))