Using Line Numbers in vi

Posted by Johan Cyprich on 11 Aug 2009 | Tagged as: How To

Debugging is easier with line numbers. The default setting for vi and vim is for line numbers in the document to be hidden.

Setting Line Numbers within the Editor

You can turn on line numbers by typing

:set number

or

:set nu

 

The line numbers can also be turned off by typing

:set nonumber

or

:set nu!

 

Making Line Numbers Default in vi

You need to edit .vimrc or .bashrc (which is normally found in the root of the user’s folders). Add the following command:

set number

vi will start with line numbers every time a document is opened.

 

Jump to a Line When Opening vi

If you know which line you would like to edit in vi, you can go right to the line when you open the document in vi from the shell.

$ vi +linenumber file.php

i.e. vi +8 file.php will open the document and place the cursor in line 8.



Tweet This Tweet This Post!

Related posts:
    How Much Money Should Programmers Make?
    How Much Money Are You Worth?
    Change IP in Linux from the Command Line
    Password Requirements for WindowsServer 2008

Share this post:

del.icio.us:Using Line Numbers in vi digg:Using Line Numbers in vi spurl:Using Line Numbers in vi wists:Using Line Numbers in vi simpy:Using Line Numbers in vi newsvine:Using Line Numbers in vi blinklist:Using Line Numbers in vi furl:Using Line Numbers in vi reddit:Using Line Numbers in vi fark:Using Line Numbers in vi blogmarks:Using Line Numbers in vi Y!:Using Line Numbers in vi smarking:Using Line Numbers in vi magnolia:Using Line Numbers in vi segnalo:Using Line Numbers in vi gifttagging:Using Line Numbers in vi

Follow Me:

Did you find this post interesting and useful? You can keep up to date on this blog by subscribing to my RSS feed, or you can have new posts sent to you by e-mail. You can also follow me on Twitter.


Trackback This Post | Subscribe to the comments through RSS Feed

Leave a Reply

CommentLuv badge