Show Line Numbers in Vi/Vim

Recently, I needed to edit a php file in Vi and although I need the line of the error, I didn’t see line numbers like I normally do in my Sublime Text 2 editor. It turns out that if you’re in Vi/Vim, you can type

:set numbers

or

:set nu

and line numbers will show up. Much better! But, that only works for the current Vi session. If you want Vi to always show line numbers, edit the .vimrc file in your home folder

vi ~/.vimrc

and append “set number” to it.