Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!


  Search this Thread
Old 01-18-2008, 02:53 PM   #1
Registered: Sep 2005
Location: New Jersey, USA
Distribution: Centos 7 , Linux Mint 18.1 Under VMware in Win7
Posts: 548

Rep: Reputation: 34
Question Setting numbers on in VI

I would like to have the numbers set on when ever I us VI to either create or edit a file.

I was told to create a file called .exrc in my home directory which I did. I included the single command set number.

Still doesn't work.

Any help will be much appreciated.

Old 01-18-2008, 03:51 PM   #2
LQ Guru
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
try setting the environmental variable EXINIT.

EXINIT="set nu"; export EXINIT
Old 01-18-2008, 03:51 PM   #3
Senior Member
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,539

Rep: Reputation: 335Reputation: 335Reputation: 335Reputation: 335
I presume you mean you would like to have line numbers displayed. The 'vi' command to enable this is:

:set nu
:set number
To disable:

:set nonu
To enable line numbering each and every time you enter 'vi', insert "set nu" in a file called ~/.vimrc.
Old 01-18-2008, 04:04 PM   #4
Senior Member
Registered: Aug 2003
Location: UK
Distribution: Slackware
Posts: 3,466

Rep: Reputation: Disabled
.vimrc is for vim.

For vi which most likely is linked to elvis (

ls -l `which vi`


the file can be ~/.exrc, ~/.elvisrc, or ~\elvis.rc

From the man page:

~/.exrc, ~/.elvisrc, or ~\elvis.rc
The .exrc or .elvisrc (for UNIX) or elvis.rc (for non-UNIX) file in your
home directory will generally be executed as a series of EX commands, unless
the EXINIT environment variable is defined. This behavior isn't built into
Elvis though; it is handled by the standard elvis.ini file.

.exrc, .elvisrc, or elvis.rc
The .exrc or .elvisrc (for UNIX) or elvis.rc (for non-UNIX) file in the cur-
rent directory is interpreted as a series of EX commands, but only if the
exrc option has been set. This behavior isn't built into Elvis; it is han-
dled by the standard elvis.ini file.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
manipulating 64 bit numbers using 32 bit numbers. rajesh_b Programming 3 09-15-2006 09:03 AM
sequence of numbers, how to extract which numbers are missing jonlake Programming 13 06-26-2006 03:28 AM
Even numbers paraiso Linux - Newbie 4 05-15-2005 03:31 PM
Error message in setting up wlan... could be i fubared some numbers. Jehar Linux - Wireless Networking 0 04-02-2005 05:24 PM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 09:18 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:09 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration