Score:0

E212 Can't open file for writing

kr flag

I was trying to add syntax highlighting to my vim which is located inside of /usr/share/vim/vimrc.

but even as sudo when I attempt to save I get the error: E212 Can't open file for writing.

Inside of vimrc I see it says "vimrc" [readonly] 14L, 5578.

How do I change that to allow for read and write?

So I ran a vim vimrc which put me in the config file, tapped down to the last line and hit the O button on the keyboard and wrote syntax on. When I went to :wq! thats when I got the error. Same thing when I run sudo vim vimrc or sudo su - then vim vimrc.

us flag
since it's a file used by vim maybe edit it with something other than vim
Daniel avatar
kr flag
@RobertLongson, I tried with my code editor and got `EPERM: operation not permitted` and this was after adding my password for sudo privileges.
muru avatar
us flag
You shouldn't be editing files in `/usr/share`. Those will be overwritten on package update. Why can't you make your own `vimrc` file in your home directory and add this there?
Daniel avatar
kr flag
@RobertLongson, so for the `vimrc` I have `-rw-r--r-- 1 root wheel`. can you suggest something better than `chmod 777`?
David avatar
cn flag
I will ask the silly question. When trying to edit this Vim file you did close Vim first?
Daniel avatar
kr flag
@David, I do not understand that question. How do you close a file and then edit it? I will clarify what I did in the post, perhaps that can help.
David avatar
cn flag
What file? I clearly meant the application.
Daniel avatar
kr flag
@David, please read above for the steps I took, hopefully that will clarify.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.