How to show line number in vim?

On CentOS Linux vim displays line numbers by default. How to how to show line number in vim on Debian Linux 10?

To make vim show line numbers, you need to use the number command.

How do I make the vim text editor display or hide line numbers?

  1. Press the Esc key
  2. Then type : (the colon)
  3. Type the following command:
    set number
  4. Numbers will appear at the left side of the vim text editor screen
  5. To turn off line numbering, again press Esc + : and then type:
    set nonumber
  6. Edit the ~/.vimrc file (vim config file)
    vim ~/.vimrc
  7. Then add the following so that vim will always display line number when you start
    set number

Sample screenshot displaying my $HOME./vimrc

You can see numbers on left side

See our guide for more info:

1 Like

That was quick, thank you. Can I copy CentOS 7 ~/.vimrc file on Debian server using scp? Do you think it will work without casing any problems? Like

scp .vimrc tomboi@10.8.0.5:$PWD

@tomboi
Yes, you can. But make sure you backup your ~/.vimrc file first on the target system, just in case. Good luck.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki