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/?
NeoZoom.lua
  • 1,442
  • 14
  • 31

2 Answers2

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

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65
  • Thank you Fabrice! Might I ask you that what is $MYVIMRC? Who will read it and what is it for? – NeoZoom.lua Jan 03 '21 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) – Fabrice Hategekimana Jan 03 '21 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.