Next: , Previous: , Up: Common requests   [Contents][Index]

5.5 How do I make Emacs display the current line (or column) number?

By default, Emacs displays the current line number of the point in the mode line. You can toggle this feature off or on with the command M-x line-number-mode, or by setting the variable line-number-mode. Note that Emacs will not display the line number if the buffer’s size in bytes is larger than the value of the variable line-number-display-limit.

You can similarly display the current column with M-x column-number-mode, or by putting the form

(setq column-number-mode t)

in your .emacs file. This feature is off by default.

The "%c" format specifier in the variable mode-line-format will insert the current column’s value into the mode line. See the documentation for mode-line-format (using C-h v mode-line-format RET) for more information on how to set and use this variable.

The ‘display-line-numbers’ package (added to Emacs in version 26.1) displays line numbers in the text area, before each line, like the “set number” capability of ‘vi’. Customize the buffer-local variable display-line-numbers to activate this optional display. Alternatively, you can use the display-line-numbers-mode minor mode or the global global-display-line-numbers-mode. When using these modes, customize display-line-numbers-type with the same value as you would use with display-line-numbers.

There is also the ‘linum’ package (distributed with Emacs since version 23.1) which will henceforth become obsolete. Users and developers are encouraged to use ‘display-line-numbers’ instead. The packages ‘setnu’ and ‘wb-line-number’ (not distributed with Emacs) also implement this feature.

Next: , Previous: , Up: Common requests   [Contents][Index]