How do I display line numbers in vim running on Linux or Unix-like operating systems?
Vim user need to type :set number command within vim text editor session when you are editing the file to display line number in vim. In this tutorial we will show you how to show line number in vim on Linux based desktop or server systems.
Start the vim editor
You need to start vim text editor. Open the terminal application and type:
How to display line number in vim
Simply type the following commands to display line number in the left margin:
- Press the ESC key
- At the : prompt type the following command to run on line numbers: set number
- To turn off line numbering, type the following command at the : prompt again: set nonumber
How to show line number in vim
To show line number along the left side of a vim window, type any one of the following command while using vim text editor. First press the Esc key. Press : and type any one of the following command at a : prompt –
How to make the vim editor display line number by default
If you need line number every time you start vim text editor, append the following line to your ~/.vimrc file:
Append the following line:
Save and close the file in vim.
Change gutter column width for numbering in vim
The vim syntax is:
Try the following in ~/.vimrc config file:
Configure text wrapping for the number column in vim
Run the following syntax within vim:
Or as usual add it to ~/.vimrc:
In this tutorial, you learned how to display line number in vim and permanently show line number in vim using $HOME/.vimrc file.