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:

  1. Open a terminal window and navigate to your home directory by running the command cd ~.
  2. Check if the .vimrc file exist in your home directory using the command ls -a .vimrc, if not create it using touch .vimrc
  3. Open the .vimrc file in Vim by running the command vim .vimrc.
  4. Press i to enter insert mode, so you can make changes to the file.
  5. Add the following line to the file:
set number
  1. Press Esc, then type :wq and press Enter to save and exit the file.
  2. 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.

Leave a Comment