How do I set line numbers in vim permanently?
You can show how to display or hide line numbers in Vim text editor using set number
command.
Showing absolute line numbers in vim
- To get the standard line numbering open your file in vim:
vim filename
- Next press the
Esc
key to switch to command mode in vim. - Press
:
(colon
) and and typeset number
orset nu
and hit theEnter
key. For example:
:set number
OR
:set nu
- Line numbers will be displayed at the left side of the vim editor.
- To disable the absolute line numbers off type the following command. Press the
Esc
key and type:
:set nonumber
In short, to show line numbers in Vim text editor, use the :set number
command for absolute line numbers, :set relativenumber
for relative line numbers. For more info see the following:
And