How do I display line numbers in Emacs (not in the mode line)?
M-x linum-mode (or global-linum-mode
), and put (global-linum-mode t)
in your ~/.emacs
(or ~/.emacs.d/init.el
) to enable it at startup.
This page:
- https://www.emacswiki.org/emacs/LineNumbers
lists a few different options.
monotux's answer is currently the first option listed there. An alternative (also listed) is NLinum:
- http://elpa.gnu.org/packages/nlinum.html
You should be able to install from ELPA:
M-x package-install RET nlinum RET
and then use it e.g. like this:
(use-package nlinum
:config
(global-nlinum-mode))
linum-mode
→ old, hack, slow. Emacs 23 (released in 2009).global-display-line-numbers-mode
→ Emacs 26 (beta as of 2018-03-30)
Put this in your emacs init file:
(when (version<= "26.0.50" emacs-version )
(global-display-line-numbers-mode))
http://ergoemacs.org/emacs/emacs_line_number_mode.html