You can configure Vim to show line numbers by default on Linux by editing the Vim configuration file, .vimrc
. Here are the steps to do this:
- Open a terminal window and navigate to your home directory by running the command
cd ~
. - Check if the .vimrc file exist in your home directory using the command
ls -a .vimrc
, if not create it usingtouch .vimrc
- Open the
.vimrc
file in Vim by running the commandvim .vimrc
. - Press
i
to enter insert mode, so you can make changes to the file. - Add the following line to the file:
set number
- Press
Esc
, then type:wq
and pressEnter
to save and exit the file. - Run the command
source .vimrc
or open a new Vim editor to see the changes.
After following these steps, the line numbers will be displayed by default whenever you open a file in Vim. If you want to turn off line numbers, you can type the command set nonumber
in the Vim editor.
Note: These steps will only affect your own Vim configuration, other users of the system will not be affected.