Monday, October 12, 2009

Show line numbers in VI - Ubuntu Linux 9.04 Jaunty/Mac OS X

Update - verified to work also with Mac OS X

From within VI
:set number

To make this behaviour the default:
user@machine:~$ cd ~
user@machine:~$ touch .exrc
user@machiner:~$ vi .exrc

Add the following line to the file:
set number
user@machine:~$ . .exrc
user@machine:~$ vi someTextFile.txt

Basically, if the file .exrc does not exist in your home directory create it.
Open .exrc for editing.
Add the line (w/o quotes) "set number"
Save .exrc
Source .exrc
Test to verify function.

Update (as I've had to look this up twice now...)
To turn off line numbers from withing VI
:set nonumber

~Fin

No comments:

Post a Comment