I have my custom Vim files in
~/.vim and settings in
~/.vimrc. However, sometimes I have to edit some files in
/etc and such.
If I start Vim like this:
$ sudo vim /etc/rc.conf
I lose my config since Vim uses its default one. So: how can I run Vim with root privileges to edit files without losing my user's settings (which are in my home directory)?
I have tried:
$ su username -c "vim /usr/lib/python2.7/setuptools/dist.py"
but Bash gives me
Permission denied. However, the above command works for example for:
/etc/acpi/handler.sh. Why is that?
Note: username is not root.