You are not logged in.

#1 2010-10-31 00:47:19

shadowtech
Member
Registered: 2010-08-06
Posts: 4

"sudo vi" configuration file?

Hi, I did some searching around and can't quite seem to come up with the answer I'm looking for.

When I perform a "sudo vi" to edit protected configuration files, it does not load the tricked out .vimrc I already have configured. I believe Arch is using the real vi (not vim) and therefore requires a .exrc config file to load in customizations.

My question is, if I'm correct in my assumptions, where should I place the configuration file for use with sudo vi? Putting it in my $HOME doesn't seem to do the trick.

Offline

#2 2010-10-31 00:57:30

ChoK
Member
From: France
Registered: 2008-10-01
Posts: 346

Re: "sudo vi" configuration file?

isn't it because it loads /root/.vimrc ?


Ah, good taste! What a dreadful thing! Taste is the enemy of creativeness.
Picasso
Perfection is reached, not when there is no longer anything to add, but when there is no longer anything to take away.
Saint Exupéry

Offline

#3 2010-10-31 01:05:25

igndenok
Member
From: Sidoarjo, Indonesia
Registered: 2010-06-07
Posts: 160

Re: "sudo vi" configuration file?

Find plugin for vim that can use sudo with

$ vim sudo:/path/to/file

And it still load your ~/.vimrc


Ask, and it shall be given you.
Seek, and ye shall find.
Knock, and it shall be opened unto you.

Offline

#4 2010-10-31 01:08:27

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,672
Website

Re: "sudo vi" configuration file?

Install vim and alias vi='vim'

Offline

#5 2010-10-31 01:23:10

shadowtech
Member
Registered: 2010-08-06
Posts: 4

Re: "sudo vi" configuration file?

ChoK wrote:

isn't it because it loads /root/.vimrc ?

Just tried out your suggestion, and it doesn't seem to load my tweaks from either .vimrc or .exrc.

Allan wrote:

Install vim and alias vi='vim'

I've read that using vim to edit some files isn't a good practice? Also, I do have this setup but using "sudo vi" will not load vim (at least not with my customizations).

Offline

#6 2010-10-31 01:40:54

schuz0r
Member
From: CA, USA
Registered: 2010-09-03
Posts: 5

Re: "sudo vi" configuration file?

shadowtech wrote:

I've read that using vim to edit some files isn't a good practice? Also, I do have this setup but using "sudo vi" will not load vim (at least not with my customizations).

I believe that this is refering to files that have seperate commands specifically to edit them ie. visudo, crontab. There shouldn't be an issue using sudo vim to edit files, at least I have never come across one.

Offline

#7 2010-11-01 14:04:52

dioltas
Member
Registered: 2009-06-03
Posts: 44

Re: "sudo vi" configuration file?

I think ChoK is right, it looks at /root/.vimrc

Just copy your ~/.vimrc to /root/.vimrc and you should be good to go.

Or else try making a symbolic link and then when you edit your vimrc the changes will be there for root too.
Or just use a global vimrc maybe.

Last edited by dioltas (2010-11-01 14:05:19)

Offline

#8 2010-11-01 14:21:59

bluepumpkin
Member
Registered: 2009-08-28
Posts: 58

Re: "sudo vi" configuration file?

I had this problem as well a while back. It seems that sudo changed its default behavior a while back. It used to leave the $HOME environment variable unchanged, but now it changes it to root's home for security reasons. If you want to revert back to the old behavior, open the sudoers file and add the line:

Defaults env_keep += "HOME"

Now vim (and any other program) will load your config files instead of root's.

Offline

#9 2012-05-11 15:49:20

kertz
Member
Registered: 2012-05-10
Posts: 1

Re: "sudo vi" configuration file?

To install for a single user just save it in their home dir at /home/username/.vimrc

All you need to do is create a home folder for root and symlink your vimrc

Ref: https://wiki.archlinux.org/index.php/Vimrc

Offline

#10 2012-05-11 17:01:33

bohoomil
Banned
Registered: 2010-09-04
Posts: 2,377
Website

Re: "sudo vi" configuration file?

Have you noticed the date on top of the last post?

2010-11-01 16:21:59

1+ year was for the OP probably enough to figure it out...


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#11 2012-05-11 18:24:04

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: "sudo vi" configuration file?

Thank you kertz but as bohoomil points out, this thread is too old: https://wiki.archlinux.org/index.php/Fo … Bumping.22.
Closing.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

Board footer

Powered by FluxBB