3

I'm re-learning Vim, and now I'm building my own ~/.vim/.vimrc file. Yes, it is store under the .vim/ folder, which is created by MacOSX after I updated to Big Sur. What I want is simply this

set belloff=all

when I put this line in ~/.vimrc it works, while in ~/.vim/.vimrc it's not. So my questions are:

  1. What's the first file Vim read so it knows Oh, so Mr. .vimrc your home is at $HOME(or ~)?
  2. Which file should I change so that Vim will say Ok, I should read Mr. .vimrc from ~/.vim/?
4
  • 2
    Have you tried to type :h vimrc and read what is written there?
    – Matt
    Jan 3, 2021 at 15:03
  • @Matt: Thank you Matt! I didn't know there is a manual for this! Jan 3, 2021 at 15:18
  • 1
    Reading Q&A How do I navigate to topics in Vim's documentation is advised. Mastering Vim's help system is a must.
    – Matt
    Jan 3, 2021 at 15:53
  • The file inside ~/.vim is vimrc not .vimrc. You only need one dot: ~/.vimrc or ~/.vim/vimrc.
    – NeilG
    Aug 13, 2023 at 13:11

2 Answers 2

5

1. For the first question

According to the help menu (see :help $MYVIMRC), vim will look for a user vimrc in specific places. It look first for ~/.vimrc and then for ~/.vim/vimrc. Vim stops searching after the first one found (that's why we need to remove ~/.vimrc).

Vim will set automatically the $MYVIMRC environment variable to the location of the vimrc used.

2. For the second question:

  1. Put your vimrc content in ~/.vim/vimrc (you must remove the ., so vimrc instead of .vimrc)

  2. Remove ~/.vimrc

2
  • Thank you Fabrice! Might I ask you that what is $MYVIMRC? Who will read it and what is it for? Jan 3, 2021 at 15:15
  • 2
    You're welcome! I am not totally sure (I'm still learning myself), $MYVIMRC is one of the global variables Vim use to start. It contains the location of the actual vimrc (you can try :echo $MYVIMRC to see it or :e $MYVIMRC to open it) What I know is that it isn't a environnement variable of the system (no need trying to change it this way) but I think you can change it inside of vim (I have seen a post here) Jan 3, 2021 at 15:26
-1

To solve the error "no .vimrc found. please set "vim.vimrc.path", you will need to create a configuration file for the Vim text editor called ".vimrc" and specify its location. Here's how to do it:

  1. Open a terminal window and navigate to your home directory: cd ~
  2. Create a new file called ".vimrc" using the touch command: touch .vimrc
  3. Open the ".vimrc" file in a text editor.
  4. Add the following line to the ".vimrc" file, replacing "path/to/.vimrc" with the actual path to the ".vimrc" file: set vim.vimrc.path=path/to/.vimrc
  5. Save the ".vimrc" file and exit the text editor.
1
  • 1
    There is no such setting as vim.vimrc.path I am flagging this answer Dec 20, 2022 at 7:40

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.