Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Editing my vimrc file on a mac [duplicate]

Tags:

vim

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?

like image 254
user3521929 Avatar asked Aug 12 '14 20:08

user3521929


People also ask

How do I edit a vimrc file?

Opening vimrc Using file name completion, you could type :e $M then press Tab until you see the desired variable. If you only want to see the path, type :echo $M then press Tab to see the variable, and press Enter. In gvim, the Edit menu includes "Startup Settings" which will use $MYVIMRC to edit your vimrc file.

Where is the vimrc file on Mac?

The path used by macOS's default vim install is /usr/share/vim/vimrc .

Where is vimrc stored?

The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.

How do I open vimrc?

In the terminal, type vi . vimrc . This will create an empty vimrc system file which you want to use. In the file, type set number , and then hit Esc on the keyboard and type in :wq .


1 Answers

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 
like image 54
Alain M. Lafon Avatar answered Oct 07 '22 17:10

Alain M. Lafon