LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Rep: Reputation: 34
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: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
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: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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, USA
Distribution: VMware V12 and V15 in Windows 10, MX Linux 23.1, Kubuntu 23.10, IBM z/VM 5.4
Posts: 558

Original Poster
Rep: Reputation: 34
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:53 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration