Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vim line numbers - how to have them on by default?

I can :set number from within a file I'm editing but how can I have them always be on by default?

like image 568
Michael Durrant Avatar asked Apr 23 '12 02:04

Michael Durrant


People also ask

How do I permanently enable line numbers in Vim?

Absolute Line Numbers Press the Esc key to switch to command mode. Press : (colon) and the cursor will move at the bottom left corner of the screen. Type set number or set nu and hit Enter .


2 Answers

Add set number to your .vimrc file in your home directory.
If the .vimrc file is not in your home directory create one with vim .vimrc and add the commands you want at open.

Here's a site that explains the vimrc and how to use it.

like image 188
Tim Pote Avatar answered Sep 28 '22 03:09

Tim Pote


To change the default setting to display line numbers in vi/vim:

vi ~/.vimrc 

then add the following line to the file:

set number 

Either we can source ~/.vimrc or save and quit by :wq, now future vi/vim sessions will have numbering :)

like image 28
abe312 Avatar answered Sep 28 '22 01:09

abe312