This page is about ''displaying'' line numbers in a buffer, or otherwise indicating line numbers, ''without'' actually changing the buffer content. If you just want to work on a specific part of the file and you are accustomed to doing that by showing line numbers in the margin, try BasicNarrowing instead.

'''See Also:''' 
* NumberLines will add the line numbers to the buffer content.
* [https://www.gnu.org/software/emacs/manual/html_node/emacs/Position-Info.html Cursor Position Information] and [https://www.gnu.org/software/emacs/manual/html_node/emacs/Display-Custom.html Customization of Display] from the EmacsManual
==Display line numbers for every line==
===Display-Line-Numbers mode===
##display-line-numbers-mode## was added in Emacs 26.  You can enable it globally by appending this to your ##.emacs## file:

    (global-display-line-numbers-mode 1)

Alternatively, to use it only in programming modes:

    (add-hook 'prog-mode-hook #'display-line-numbers-mode)

The variable `display-line-numbers' may be used to control the type of line numbers that are displayed (absolute/relative/visual).

===Linum mode===
Obsolete from Emacs 29, see LinumMode.
== Display the current line number in the mode line==
Use <code>M-x line-number-mode</code>.

== Display the current line number once==
To display the current line number in the EchoArea, you can
* use <code>M-x what-line</code> command
* use <code>count-lines-page</code> (<kbd>C-x l</kbd>), which reports the total number of lines as well as the numbers of lines before and after the current one.

==External packages==
===line-num===

[[line-num.el]]

===LineNo===
LineNo
===LinumPlus===
LinumPlus

===Nlinum===
See [[Nlinum]]
===Setnu===
See [[Setnu]]
===XEmacs line-numbers-mode===

JerryChen had [http://www.geocities.ws/gchen275/xemacs/ a line-numbers-mode on Geocities]. It seems to be [[XEmacs]] specific.
[http://www.geocities.ws/gchen275/xemacs/line-numbers-mode.gif Screenshot].

----
CategoryDisplay
