I can :set number
from within a file I'm editing but how can I have them always be on by default?
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 .
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.
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 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With