I'm using CentOS and created a .vimrc
file in my /home
directory. I tested it out by creating a txt file and yes, that worked fine. Now, I have my project files in my /srv
directory with SELinux turned on. I tried opening a file: vim README.txt
and yes, my .vimrc
settings are still being applied.
Now, since I'm in the /srv
directory, simply doing vim
means that my file is read only. So, I do sudo vim README.txt
in order to be able to edit files. Now, the problem lies that once I do sudo
, none of my .vimrc
settings are applied. I tried creating a copy of .vimrc
in the /srv
folder but that didn't work either.
How do I apply .vimrc
settings while using sudo
?
sudo
, you switch yourself to theroot
user, so$HOME
becomes the/root
directory (unless the-E
option is used). That meansvim
will load the configuration in/root/.vimrc
.vim
is not configured to load the configuration from the current directory by default, that's why it didn't load it from the/srv
directory. – Dawid Ferenczy Rogožan Aug 5 '16 at 14:52