1

I am having an issue where anything I enter into my .vimrc file is not being picked up, regardless of how many times I add it / close the file / re-open it, etc. Here is the most basic example of what I came up with: https://gyazo.com/ae18bd40f4dec269fb36d723865d5efe.

As you can see, entering in

inoremap    xxx1 hello

Into my vimrc file does absolutely nothing. However, as soon as I type that command in directly it works just fine. So, what might be going on here? (Note that some commands I have in my vimrc file from previous do work.

Note the above command has been in my vimrc file for days, so the question isn't asking about how to refresh an already-opened vimrc file, but basically why the commands there aren't being recognized anymore.

6
  • 1
    @filbranden of course. I was doing that. Also saving it and re-opening the file to make sure everything is being re-loaded. Commented Aug 16, 2022 at 0:36
  • 1
    @filbranden updated the question for clarity! Commented Aug 16, 2022 at 0:37
  • 2
    Are you sure that's your actual vimrc file? In Linux/Unix the file path is ~/.vimrc with a . at the beginning of the name. In Windows it's _vimrc. Is it in your home directory? You can actually use :e $MYVIMRC to edit the actual file (assuming it exists.)
    – filbranden
    Commented Aug 16, 2022 at 0:39
  • 1
    @filbranden yes, thank you!! Oh that was driving me crazy thanks so much for that note. Not sure why I add an extra file named vimrc in the .vim directory. Want to post it as an answer? Commented Aug 16, 2022 at 0:46
  • 1
    Ah! The ~/.vim/vimrc file is a valid file path... But if the ~/.vimrc file exists, it takes priority. Yes, I'll post an answer.
    – filbranden
    Commented Aug 16, 2022 at 0:47

1 Answer 1

2

After some discussion in the comments, it turns out that the vimrc file you were editing was the ~/.vim/vimrc file. But the ~/.vimrc file takes priority when it exists. So Vim was ignoring your ~/.vim/vimrc because it was being shadowed by the existing ~/.vimrc file.

As a solution, either keep using ~/.vimrc exclusively, or migrate all its contents to ~/.vim/vimrc and remove that file completely.

See :help .vimrc:

Five places are searched for initializations. The first that exists is used, the others are ignored. The $MYVIMRC environment variable is set to the file that was first found, [...]

  1. [...]
  2. The user vimrc file(s):
  • $HOME/.vimrc (for Unix) (*)
  • $HOME/.vim/vimrc (for Unix) (*)
  • ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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