Emacs: Show Line Numbers
emacs has 2 line numbers mode.
linum-mode→ old, hack, slow. Emacs 23 (released in ).
global-display-line-numbers-mode→ Emacs 26 (released in 2018-05)
Emacs 26 (released in 2018-05) has a new line number mode.
global-display-line-numbers-mode→ show line numbers in all buffers.
display-line-numbers-mode→ show line numbers in current buffer.
Put this in your emacs init file:
(when (version<= "26.0.50" emacs-version ) (global-display-line-numbers-mode))
display-line-numbers-mode is written by Eli Zaretskii. Thanks Eli.
Emacs 23 (released in ) has a line number mode. It shows line numbers in margin. [see Emacs 23.1 New Features (released 2009-07)]
linum-mode→ toggle line number in current.
global-linum-mode→ toggle line number in all buffers.
To set it permanetnly, put this in your emacs init:
(global-linum-mode 1) ; always show line numbers
How to set linum line number to start at 0?
If you want line number to start at 0, put this in your emacs init file:
(require 'linum) (setq linum-format (lambda (line) (propertize (number-to-string (1- line)) 'face 'linum)))
Setting line number to start at 0 is useful because some editors do that. See: bug#4274.
linum-mode is written by Markus Triska. Thanks Markus.
Jump to a Line Number
goto-line → move cursor to a given line position.
If you have a question, put $5 at patreon and message me.