So I tried to change the default colour scheme of vim to desert thinking it was going to be a simple task but I ended up getting caught in a rabbit hole.

I normally create a web pages using sudo webpage.html as it is just me on the network right now even though it is considered bad practice to use sudo. Whatever, opportunity cost, I'm just trying to get stuff done here not be The Creator of Wizardry. However, the perfectionist in me requires me to become my best at anything I do so let's drill down here.

Problem: When I sudo vim webpage.html I do not see desert colour scheme even though when I "sudo vim ~/.vmrc" I see

 1 set number
 2 colo desert
 3 syntax on

I was expecting to see "sudo vim webpage.html" pick up the desert colour scheme here. How do I achieve this desired result?

Now, when I vim webpage.html I see desert colours and she is beautiful but when I go to save changes I get bottle-necked with:

E45: 'readonly' option is set (add ! to override)

okay so I :wq! and now get E212: Can't open file for writing How do I fix this issue? Seems like a file permission issue current permissions is -rwxr-xr-x. If I have to change every file to a different permission with a new command line I am not interested in this option as it creates more non revenue producing keystrokes for me.

If I could set desert colour as default for all future users on the network and sudo user while being able to save that would make me a happy panda.

Thanks for caring.


1 Answer 1


I think what's happening is that you're mixing users. You should try to work only under 1 user account, ideally as a non-root user.

When you do this:

sudo vim webpage.html

you're executing the vim command as the user root. When you save it, the file permissions are set for the root user.

When you do this:

sudo vim ~/.vmrc

You're opening the file at /home/normaluser/.vimrc as the user root. Not as normaluser.

It makes sense that this:

vim webpage.html

works because this would actually use the file at /home/normaluser/.vimrc.

It also makes sense that you can't modify the file as a non-root user because the file belongs to root.

tl;dr Either work as root all the time or work as a normal user all the time. If you have to work as root (not recommended), then you'll probably want to add your color scheme to /root/.vimrc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .