As to the built-in line numbers that have been available since Emacs 26 [display-line-numbers-mode
], it is not possible to display line numbers within the window margin or to the left of the window margin -- the built-in line numbers are displayed inside the text area
. The deprecated Lisp versions of line numbers display within the window margin [linum
and nlinum
], and it is likely possible to configure/tweak them so that the numbers are left-aligned.
The following is a link to a helpful diagram of the window layout:
https://www.gnu.org/software/emacs/manual/html_node/elisp/Basic-Windows.html
The following is a quote from the commentary of visual-fill-column-mode
describing how the mode modifies the window-margin(s) to achieve the visual effect:
https://github.com/joostkremers/visual-fill-column/blob/master/visual-fill-column.el#L31
;;; Commentary:
;; visual-fill-column-mode' is a small Emacs minor mode that mimics the effect ;; of
fill-column' in visual-line-mode'. Instead of wrapping lines at the ;; window edge, which is the standard behaviour of
visual-line-mode', it wraps
;; lines at fill-column' (or
visual-fill-column-width', if set). This is
;; accomplished by widening the margins, which narrows the text area. When the
;; window size changes, the margins are adjusted automatically.
;;
;; When visual-fill-column-center-text' is set, the text is centered in the ;; window. This can also be used in combination with
auto-fill-mode' instead
;; of `visual-line-mode', or in programming modes.
display-line-numbers
are interested in changing the current number line implementation to something similar to the deprecated versions. (linium
|nlinum
) – Icy-Thought Jan 19 '24 at 15:44emacs-devel
introduction of native line numbers by Eli Zaretskii on June 17, 2017: https://lists.gnu.org/archive/html/emacs-devel/2017-06/msg00318.html The thread contains discussion as to advantages v. disadvantages of using the text area versus the display margin; e.g., support for line numbers with bidirectional text. My recollection is that there was also a thread on reddit / emacs at same time, which if that thread still exists, may contain additional interesting discussion. – lawlist Jan 19 '24 at 22:29linum
on June 15, 2014 -- three (3) years before Eli wrote the native implementation: https://lists.gnu.org/archive/html/bug-gnu-emacs/2014-06/msg00562.html – lawlist Jan 19 '24 at 22:43nlinum-relative
was not as quick as I'd hoped it would be, but it was exactly what I wanted it to be. The performance side alone had me go back todisplay-line-numbers
and disable it in org-mode instead of using an alternative. I guess I'll have to wait it out until I learn some elisp or find an alternative solution to this problem. Nonetheless, appreciate the help! :) – Icy-Thought Jan 25 '24 at 03:10