How to show row numbers in Emacs

Welcome to my Emacs for noobs series. Today: line (row) numbers, which are one of the first things people notice is missing when they open Emacs for the first time.

Enable line numbers in the current buffer

Hit M-x and call:

display-line-numbers-mode

That is it. Line numbers appear immediately in the current file.

Enable line numbers everywhere

If you want them globally across all buffers:

global-display-line-numbers-mode

Making it permanent

The above methods are session-only. To persist the setting, add one line to your Emacs configuration file. If you are not sure where that file is, check the companion post on how to change your Emacs theme which also covers moving your config to the right location.

Open your ~/.config/emacs/init.el and add:

(global-display-line-numbers-mode)

Save with C-x C-s, restart Emacs, and the numbers will be there every time.