I was just wanted to confirm that what I’ve done won’t cause some issue which I don’t know about.
So I’ve started learning about vim recently and have configured my ~/.vimrc. I noticed soon after that when I ran a command with sudo that my preferred settings weren’t working.
After some googling I found out that root has it’s on settings and files etc and the solution to make my .vimrc settings run with sudo is to run sudo -E vim [filename]. I didn’t want to have to always use the -E flag every time I ran sudo with vim so I searched a bit more and found this: sudo cp ~/.vimrc /root/.vimrc.
Is there an issue with copying my .vimrc to root’s .vimrc?
/etc/vimrc is where the system wide settings are kept, maybe I should do sudo cp ~/.vimrc /etc/vimrc ?
Nope, you just have two copies now (so if you make a change you want in both then you have to keep them in sync).
That file is installed by the vim-runtime package so you’ll have to merge any changes when that package is updated. If you can, it’s normally better to set configuration outside of packaged files.
In the timeshift user settings I have excluded all root files so when I go back to my last snapshot the ~/.vimrc which I copied to /root/.vimrc is still there.
two questions.
Is it really a problem to be keeping my ~/.vimrc and `/root/.vimrc in sync together?
regarding timeshift user settings I have my home/user to include only hidden files which is what I want. But for root should I include only hidden files or include all files?
Root shouldn’t have many files, so depends what you want. I’d probably not be using Timeshift for anything other than OS files (i.e. I wouldn’t want to revert changes to documents and emails if a system update failed).
I was always a bit confused about the user options in timeshift I’m glad that’s been clarified, I suppose it was because I didn’t understand that root is also a User.
If I ran sudo pacman -Rns gvim wouldn’t that remove the ~/.vimrc and also /root/.vimrc?
Then I could reinstall gvim change timeshift settings and start again
@jonathon I know you said it isn’t an issue and I take your word on that, I just thought maybe I could revert the changes with pacman -Rns and try the other solution so I don’t have to keep them both synced
I keep mine in sync through a symbolic link (symlink). The root .vimrc points to my user .vimrc. This way, if I edit the .vimrc file it affects both root and my user.
@2000 Big thank you to you. I have heard a lot about symbolic links here and there but I didn’t really understand what they are except that they are commands that start with ln and link two things somehow. Your example has made it much clearer for me.
so either I can 1. make an alias in .bashrc to sudo -E vim or 2. use a symbolic link to join the root and home users .vimrc.
alias svim='sudo -E vim'
sudo ln -sf ~/.vimrc /root/.vimrc
Its good there are many ways to do things in Linux, lol its just a matter of finding out how to do them.
I didn’t get you. If I for example just changed my .bashrc then when I edit a file with my normal user account with sudo it will have my .vimrc settings and without sudo it will have my .vimrc settings
if i put alias svim=‘sudo -E vim’ in .bashrc then with my account i write svim [filename] that should make sudo take the .vimrcsettings. And without sudo of course my settings will be from~/.vimrc`