How To: Vim show line numbers by default on Linux
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
.vimrcfile in Vim by running the commandvim .vimrc. - Press
ito enter insert mode, so you can make changes to the file. - Add the following line to the file:
set number
- Press
Esc, then type:wqand pressEnterto save and exit the file. - Run the command
source .vimrcor 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.
