I know that you can toggle line numbers with the key combination SPC + t + l
but it changes back to absolute line numbers when restarting Doom Emacs. How can I configure Doom Emacs to set relative line numbers every time I start emacs?
As of commit a7da9a4 doom-line-numbers-style
has been removed. The correct way of setting line number type is to set the display-line-numbers-type
variable. This is part of Emacs itself and as such will work outside of doom too.
To answer op's question, the way to set line numbering to be relative is to add the following snippet to your configuration file which in the case of doom is ~/.doom.d/config.el
.
(setq display-line-numbers-type 'relative)
Assuming on latest version, which is v2.0.9 at the time of writing, the preferred way would be to set the doom-line-numbers-style
to 'relative
in your own private config. Simply add (setq doom-line-numbers-style 'relative)
to that config. This will configure emacs to start with relative line numbering.
Note however that toggling line numbers with SPC t l
will still change it back to absolute line numbering. To toggle relative line numbering, you need to provide a universal argument to the toggle command. In this case, you'd have to do SPC u SPC t l
. The SPC u
there stands for the universal/prefix argument.
© 2022 - 2025 — McMap. All rights reserved.
(setq display-line-numbers-type 'relative)
inside your init.el. – Immeasurable