11

It seems that Emacs 29.1 has deprecated linum-mode. I haven't found a replacement yet. On ELPA I see nlinum-mode, but that seems to use linum, too. So what is the official replacement?

1
  • If you take a look at linum.el, you will see "Consider using native line numbers instead: M-x display-line-numbers-mode"
    – shynur
    Aug 7, 2023 at 8:47

1 Answer 1

14

Simply C-hn in Emacs 29 and C-s for linum to easily find this news:

** The linum.el library is now obsolete.
We recommend using either the built-in 'display-line-numbers-mode', or
the 'nlinum' package from GNU ELPA instead.  The former has better
performance, but the latter is closer to a drop-in replacement.

1. To use 'display-line-numbers-mode', add something like this to your
   init file:

    (global-display-line-numbers-mode 1)
    ;; Alternatively, to use it only in programming modes:
    (add-hook 'prog-mode-hook #'display-line-numbers-mode)

2. To use 'nlinum', add this to your Init file:

    (package-install 'nlinum)
    (global-nlinum-mode 1)
    ;; Alternatively, to use it only in programming modes:
    (add-hook 'prog-mode-hook #'nlinum-mode)

3. To continue using the obsolete package 'linum', add this line to
   your Init file, in addition to any existing customizations:

    (require 'linum)

The fast/efficient display-line-numbers-mode has been included since Emacs 26.1.

3
  • (perhaps) off-topic: "using either the built-in display-line-numbers-mode, or the nlinum package from GNU ELPA" -- so we can display both absolute and relative line numbers at the same time by using both packages.
    – shynur
    Aug 7, 2023 at 9:04
  • 1
    Thank you especially for the hint to look at the news. I forgot that that's a thing!
    – A Schmitz
    Aug 7, 2023 at 9:23
  • This is great, thanks so much for the detailed submission
    – cstls
    Aug 9, 2023 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.