How to display line numbers in vim using .vimrc file

You can display line numbers in Vim by adding the following line to your .vimrc file:

set number

The .vimrc file is a configuration file for Vim, and any settings specified in this file will be applied every time you start Vim.

Once you have added the above line to your .vimrc file, you can start or restart Vim to see line numbers displayed in the editor. To turn off line numbering, you can simply remove the line from your .vimrc file or comment it out by adding a “” character at the beginning of the line.

Here’s an example of how your .vimrc file might look after adding the line to display line numbers:

" .vimrc file
set number
"
other settings...

Note that you may need to create the .vimrc file if it does not already exist. The .vimrc file is usually located in your home directory. To edit the file, you can use any text editor, such as Vim, nano, or gedit.

Leave a Comment