How can I edit the default vimrc file on osx? (sudo chown ... gives Operation not permitted )

In osx vim /usr/share/vim/vimrc is the default vimrc file

My username is 'apple'

If I try to do vim /usr/share/vim/vimrc then it says 'read only'

~/.vim$ ls -l /usr/share/vim/vimrc -rw-r--r-- 1 root wheel 532 5 Apr 2017 /usr/share/vim/vimrc ~/.vim$

If I try to change ownership of the file

~/.vim$ sudo chown apple /usr/share/vim/vimrc 
chown: /usr/share/vim/vimrc: Operation not permitted

similarly with permissions (giving write access to non-root users temporarily for the purposes of me editing the file)

~/.vim$ sudo chmod 666 /usr/share/vim/vimrc
chmod: Unable to change file mode on /usr/share/vim/vimrc: Operation not permitted

sudo chown does work on another file though, so it's not a password issue.

~/.vim$ cp /usr/share/vim/vimrc zzz
~/.vim$ ls -l zzz
-rw-r--r--  1 apple  staff  532  3 May 23:10 zzz
~/.vim$ sudo chown root zzz
~/.vim$ sudo chown apple zzz
  • You should not overwrite the system vimrc for various reasons. One being that with a system upgrade it will be overwritten. link
    – modlin
    May 3, 2019 at 22:36
  • @modlin i'm only looking to change one line, and it's my computer. So even if it's not recommended to do so, I want to do so. I'm asking how
    – barlop
    May 3, 2019 at 22:39
  • What are you trying to change? There's probably a way to do this with a .vimrc file in your home directory, rather than making a change to a system file.
    – user101978
    May 4, 2019 at 6:29
  • @duskwuff of course it can be done from the file in the ~/.vim/vimrc, but I want to change the file that runs first. As to why, it's a personal preference that if one particular feature of vim is so utterly ridiculous, I want to turn it off in the main file. Then put my customizations in the home dir vimrc. Then if I have different vimrcs can do vim -S a.a or vim -S b.b (where a.a or b.b are vimrc files), and they'll all run shortmess=I from the main file
    – barlop
    May 4, 2019 at 7:13

1 Answer 1


This would be a System Integrity Protection (SIP) issue. See About System Integrity Protection on your Mac. Error message shown below is often displayed when SIP prevents a command from executing.

Operation not permitted

Basically, you need to either temporarily disable SIP or edit the file while booted to macOS Recovery.

You must log in to answer this question.

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