46

I'm using Mac OSX (10.9) and I'm trying to configure my vimrc file by adding "set number". I found my vimrc file in user/share/vim/ but I can't edit it because it's read-only. How can I fix this and read it?

2
  • 9
    This is not a duplicate, guys, stop it. If you want to open the vimrc file you can do it by typing: sudo vim ./vimrc in the user/share/vim folder Feb 20, 2015 at 9:41
  • 7
    This question concerns editing the system vim file v.s. the user-created vim file on Mac. How is it a duplicate of the supposed "No vimrc, gvimrc and .vim on mac" post?
    – Sean
    Dec 9, 2016 at 4:48

1 Answer 1

102

You should not overwrite the system vimrc for various reasons. One being that with a system upgrade it will be overwritten.

Instead you can create a new .vimrc file in your home directory. Open the terminal and enter:

 vim ~/.vimrc

There you can enter your various configurations. When done, you need to save the file and restart vim.

To be sure which vimrc is being used, you can ask inside of vim by typing:

 :echo $MYVIMRC 
6
  • 18
    So to emphasize, /usr/share/vim/.vimrc is not "your" file; anything outside of /home/you is a system file which you should not muck with in the vast majority of cases.
    – tripleee
    Aug 12, 2014 at 20:13
  • 2
    On my own computer, as root I want to be able to muck with whatever I want. And I wanted vim to behave uniformly regardless if I was root or any other user. So, it would be logical to set certain things globally instead of having a number of user-specific config files. All in all, the original question is not answered. Feb 23, 2018 at 16:13
  • @SzilardBarany yeah and we agree it is your file if it's your computer, maybe this will help , in the case eg of a mac where eg sudo vim /usr/share/vim/.vimrc doesn't cut it apple.stackexchange.com/questions/359319/…
    – barlop
    May 4, 2019 at 6:05
  • @Munen. Thank you for the comment. A question: once you have created the .vimrc file, how do you do to access it (find it) and edit it?
    – ecjb
    Jun 22, 2019 at 15:27
  • 1
    @ecjb I'm not sure I understand the question. If you're asking how I find the file, my answer is that the .vimrc file for your logged in user will be in the home directory of said user. Therefore, I'd find and edit it using this command: vim ~/.vimrc Jun 23, 2019 at 16:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.