I wrote


to edit my vimrc and after adding my edits. I wanted to save and exit :wq but then it says:

E505: C:.... is read only press ! to override

so I write :wq! but it doesn't exit the document and it says:

... E212 can't open file for writing

For Maxim enter image description here

enter image description here

  • You’re in the right place :) welcome
    – D. Ben Knoble
    Aug 24 '20 at 13:20
  • All vimrc files are in incorrect locations again
    – Maxim Kim
    Aug 25 '20 at 17:02
  • @MaximKim I put it in C:\Users\username\vimfiles\vimrc as suggested
    – user31082
    Aug 26 '20 at 6:15
  • vimrc should be a file in vimfiles/ subfolder
    – Maxim Kim
    Aug 26 '20 at 6:20

Probably you don't have local user .vimrc.

$MYVIMRC is pointed to the one that was used to initialize your vim. If there is no user .vimrc it would be system-wide one and usually you would have to edit it with superuser rights.

So in vim, do :e ~/.vimrc and add your settings there. Bear in mind there is also defaults.vim (:h defaults.vim) that is loaded if there is no user .vimrc... meaning you wouldn't get all the things from there unless you add them explicitly.

PS, better place for your settings is a ~/.vim/vimrc if you plan to store you config on a github/gilab/whatever.

PPS, you have added vimrc file to a vimfiles/vimrc/ folder and it should be vimrc in vimfiles/. Check :h viminit

II  The user vimrc file(s):
        "$HOME/.vimrc"     (for Unix) (*)
        "$HOME/.vim/vimrc"     (for Unix) (*)
        "s:.vimrc"         (for Amiga) (*)
        "home:.vimrc"      (for Amiga) (*)
        "home:vimfiles:vimrc"  (for Amiga) (*)
        "$VIM/.vimrc"      (for Amiga) (*)
        "$HOME/_vimrc"     (for Win32) (*)

----->  "$HOME/vimfiles/vimrc" (for Win32) (*) <----- HERE

        "$VIM/_vimrc"      (for Win32) (*)
        "$HOME/config/settings/vim/vimrc"   (for Haiku) (*)

enter image description here

  • I have looke in my C:\users foldder and youre right there is no local/personal vimrc . If I make a new folder and document for my vimcr, it will be blank - how will I add the things needed. On this video: youtube.com/… it has a large if command which is what I saw in $MYVIMRC
    – user31082
    Aug 24 '20 at 18:55
  • On windows create a file C:/Users/YOURUSERNAME/_vimrc or C:/Users/YOURUSERNAME/vimfiles/vimrc
    – Maxim Kim
    Aug 24 '20 at 19:00
  • Done. Now, there is an error message when I open gvim that says Cannot source a directory: "$HOME\vimfiles\vimrc "
    – user31082
    Aug 24 '20 at 19:12
  • 1
    @user716881 You should create a vimfiles directory, but vimrc inside it should be a file.
    – filbranden
    Aug 24 '20 at 21:10
  • 1
    @MaximKim Thanks
    – user31082
    Aug 26 '20 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy