Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I login as root or edit a file by sudo mode all of the options in my /etc/vimrc are not working (e.g. highlight line-number etc.)

share|improve this question
    
Does user root have a vimrc? –  Mat Mar 13 '12 at 11:15
1  
i config at /etc/vimrc –  asdf Mar 13 '12 at 11:28
    
What does :echo $VIM (in vim) tell you? (According to my understanding of :help system-vimrc, the global vimrc is expected to be $VIM/vimrc) –  sr_ Mar 13 '12 at 11:39
    
$VIM is /usr/share/vim –  asdf Mar 13 '12 at 12:06
    
You could try placing a copy of your vimrc in /usr/share/vim/ (while I do not understand why /etc/vimrc is read at all when vim is started by a normal user) –  sr_ Mar 13 '12 at 13:07

2 Answers 2

up vote 5 down vote accepted

I guess the reason is that your home directory ~ is changed, where contains vim configuration file .vimrc .

Normally ~ is /root if you login as root, and is /home/YOURNAME if you login as YOURNAME.

share|improve this answer
    
i'm config option in /etc/vimrc. –  asdf Mar 13 '12 at 11:28

Which vimrc are you talking about? I don't use/know vim, but in many cases rc files have two kinds of "incarnation": a system-wide rc-file under /etc that dictates the system defaults for the application and user-wide rc-files under the user homedirs, where users set their own settings, that override the defaults from the system-wide configuration file.

Meanwhile, there is sudo, that runs a program as another user (usually root, maybe, like su, it allows you to impersonate users other than root).

As you're running vim through sudo, my guess is that you're expecting ~/.vimrc to be something that it isn't. Either that, or you don't understand what is sudo doing when you invoke it.

If it really is ~/.vimrc, then it's not "not working", it's actually working quite well, the issue is that there's probably no ~root/.vimrc, or it exists with different settings than these you were expecting.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.