Vim is a popular text editor used for its efficiency in handling text, code, and configuration files. One of its useful features is the ability to show line numbers, which helps in navigating through the file, especially when debugging or referring to specific lines. Line numbering in Vim can be easily enabled or disabled depending on the user's preference.
Vim provides both absolute and relative line numbering. Absolute numbering shows the exact line number for every line in the file, while relative numbering shows the number of lines relative to the current line. Understanding how to enable or disable these options and customize them for your workflow can improve navigation and productivity.
Additionally, you can make line numbering settings permanent by editing the .vimrc file. This ensures that line numbering behaves consistently across all Vim sessions.
:set number
:set nonumber
:set relativenumber
Relative numbering shows how far each line is from the current line.
:set norelativenumber
:set number relativenumber
This displays the current line number as absolute and all other lines as relative numbers.
vim ~/.vimrc
set number
set relativenumber
:wq