SPC t n menu toggles line numbers, showing consecutive (absolute)
r or visual
.spacemacs file to show line numbers by default.
Relative line numbering for Vim-style editing
A relative numbering style (
relative) is highly recommended for vim-style editing as it provides an effective way to apply actions to multiple lines
10 j in Evil normal mode will jump 10 lines forward
g c 9 j will comment 9 lines from current, downwards
24 g r j will select multiple cursors for the next 24 lines
With relative numbering, the current line number is shown and all other numbers are relative to the number of lines away they are from the current line. Relative numbering is useful for jumping to different parts of your file or running commands on a number of lines, eg. delete, indent, multiple cursors (
Visual style line number configuration
Practicalli recommends using visual line numbers for Vim style editing, which provides relative numbering that does not count hidden or folded code.
SPC f e d to open the
.spacemacs file and
SPC s sdotspacemacs-line-numbers` to jump to the configuration option.
Add this configuration and
SPC f s to save the file.
SPC f e R to reload the configuration (or
SPC q r to restart Spacemacs).
dotspacemacs-line-numbers '(:visual t :disabled-for-modes dired-mode doc-view-mode pdf-view-mode :size-limit-kb 1000)
The configuration provides visual line numbers for buffers all buffers except dired, doc-view and pdf-view buffers.
Line numbers are also disabled for large files, as it can slow Emacs down considerably (although this may be less of a problem with Emacs 26.3 onward and native line numbers).
If you want to turn line numbers off for all buffers by default, set the value back to the default
Jumping to a line without line numbers
SPC j l will jump the cursor to the specified line by temporarily labelling each line with a unique letter combination. This allows you to jump quickly to a line even if you are not using line numbers.