LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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!

Notices

Reply
 
Search this Thread
Old 02-23-2013, 01:55 PM   #1
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit), USA
Distribution: Centos 5 Under VMware in WinXP CentOS 5.3 all under VMware
Posts: 414

Rep: Reputation: 33
VI Line Number Problem


Greetings all,

I needed to have line numbers when I either edit or create new members with VI

I created the file .vimrc in /home/myuserid and included the line ‘set num’ (no quote marks) and it worked fine.

However when I do an su on my user id to do administrative tasks and have to use VI the line numbers no longer appear.

I'm using CentOS 6.3 and Gnome.

How can I resolve this problem?

Thanks
 
Old 02-23-2013, 02:31 PM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
The .vimrc file you created is only used by that specific user (/home/myuserid).

You have 2 possibilities:

1) also create a .vimrc for the root user,
2) make it global for all users and add it to /etc/vimrc
 
1 members found this post helpful.
Old 02-23-2013, 02:35 PM   #3
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit), USA
Distribution: Centos 5 Under VMware in WinXP CentOS 5.3 all under VMware
Posts: 414

Original Poster
Rep: Reputation: 33
Thanks druuna,

Do I need a '.' in front of the vimrc file (.vimrc) in the etc directory?
 
Old 02-23-2013, 02:38 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Quote:
Originally Posted by swamprat View Post
Thanks druuna,

Do I need a '.' in front of the vimrc file (.vimrc) in the etc directory?
Nope, you don't.

The dot version (.vimrc) is only used in the users/root home-directory.

Isn't there a /etc/vimrc already? Most distro have one (maybe it is stored in /etc/vim/vimrc, do check).
 
1 members found this post helpful.
Old 02-23-2013, 03:55 PM   #5
swamprat
Member
 
Registered: Sep 2005
Location: New Jersey, (Which Exit), USA
Distribution: Centos 5 Under VMware in WinXP CentOS 5.3 all under VMware
Posts: 414

Original Poster
Rep: Reputation: 33
druuna,

There is a vimrc file in the etc directory and it is a script. which I backed up and add the set nu line.

Logged off and back on did a vi test but on line numbers but it didn't work.

I found a file in the etc directory called virc backed it up and add the set nu line to the active virc file and now when I su to root or just su the line numbers are there.

Thank you again for leading me down the right path.
 
  


Reply


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
How to delete single line from file using line number. gajananh999 Linux - Newbie 1 08-13-2012 05:25 AM
[SOLVED] Insert line using sed or awk at line using line number as variable sunilsagar Programming 11 02-03-2012 10:48 AM
[SOLVED] Trying to number every other line and append those numbers to end of line kmkocot Programming 7 04-23-2010 11:17 AM
Create File Listing in C++ that will generate a line number on every line of code marzrocks Programming 11 04-12-2010 06:10 AM
bash : read every line from text file starting at given line number quadmore Programming 4 02-20-2009 12:29 PM


All times are GMT -5. The time now is 06:41 PM.

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