You are not logged in.
Hi, Im getting really confused with vim and its /etc/vimrc config, and the per user ~/.vimrc.
On one of my PC's I have an untouched /etc/vimrc and a /home/jason/.vimrc which has:
syntax onnow, on that same PC, if I run
vim .vimrc"syntax on" in green and yellow as expected, and if I run
sudo vim .vimrcI also see
"syntax on" in green and yellow, but surely this is opening it as root?
*Edit
Even though there is no .vimrc in /root, and the system-wide /etc/vimrc is untouched/blank
On another PC I also have an untoched /etc/vimrc, and a /home/jason/.vimrc which has:
syntax onAswell, and:
vim .vimrchas "syntax on" in green and yellow as expected, but this time:
sudo vim .vimrcHas no colour?
I cant explain this, any ideas?
*Edit
To clarify, both PC's have an untouched /etc/vimrc and there is no /root/.vimrc file on either PC
Last edited by jrussell (2013-04-14 10:21:42)
bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U
Offline
The configuration files in /etc are for system-wide settings. These are the default settings if not overridden by a user's own settings in their home directory.
So running vim as your regular user will use the settings from your home directory.
What does sudo? From man sudo
sudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.
So if you didn't specify any setting in the home folder of the user you want to run vim as, and you don't have anything in /etc/vimrc, vim won't apply any custom settings.
Offline
The configuration files in /etc are for system-wide settings. These are the default settings if not overridden by a user's own settings in their home directory.
So running vim as your regular user will use the settings from your home directory.
What does sudo? From man sudosudo allows a permitted user to execute a command as the superuser or another user, as specified by the security policy.
So if you didn't specify any setting in the home folder of the user you want to run vim as, and you don't have anything in /etc/vimrc, vim won't apply any custom settings.
I understand all of that, but on both my PC's I have a clean/untouched config /etc/vimrc, and both /root/.vimrc files do not exist, so howcome on one PC I get colour with sudo vim...., and on the other I dont?
bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U
Offline
Check the output of
sudo echo $HOMEon both systems. If they are different, make sure that you don't have any aliases or environment variables that affect sudo's behavior.
My Arch Linux Stuff • Forum Etiquette • Community Ethos - Arch is not for everyone
Offline
Check the output of
sudo echo $HOMEon both systems. If they are different, make sure that you don't have any aliases or environment variables that affect sudo's behavior.
on both PC's it returns the home directory of the logged in user, both users are in the sudoers file with the same setup, (the usernames are not the same)
bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U
Offline
I think in one case environmental variables are passed with sudo, and in the other not.
You can check, if you open a root shell with su -, so it will load the root env vars. From this shell run vim.
Offline
I think in one case environmental variables are passed with sudo, and in the other not.
You can check, if you open a root shell with su -, so it will load the root env vars. From this shell run vim.
If I run
suand login as root and run vim on both PC's I get no colour, which is expected
bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U
Offline
Have you altered sudoers on the machine that has syntax working using elevated priviledges?
Offline
Have you altered sudoers on the machine that has syntax working using elevated priviledges?
Got it.
I had added
Defaults env_keep += "HOME"to the bottom of the sudoes file on the PC that was keeping my options across sudo.
bitcoin: 1G62YGRFkMDwhGr5T5YGovfsxLx44eZo7U
Offline