March 27, 2010

Vi display line number

Quite a few times its been useful to see the line number while editing a file. Easily done too :')

Heres our poor file without an line numbering.....

Now we use the command

:set number (the colon is needed too)
and it gives us this :)

You can revert to no lines again by using

:set nonumber (again notice the colon is part of the command)
Opening a file with line numbers showing by default can be do with creating or adding to a file ~/exrc and adding the line
set number
Have fun!