Where can I find vimrc file in Windows?

Viewed 8118

I've recently installed vim text editor on my Windows. I've looked for any explanation about the location of vimrc file on Google, but I couldn't find any meaningful explanation. Where can I find vimrc file ?

3 Answers

From :h vimrc:

Places for your personal initializations:
    Unix        $HOME/.vimrc or $HOME/.vim/vimrc
    MS-Windows  $HOME/_vimrc, $HOME/vimfiles/vimrc
            or $VIM/_vimrc
    Amiga       s:.vimrc, home:.vimrc, home:vimfiles:vimrc
            or $VIM/.vimrc

The files are searched in the order specified above and only the first
one that is found is read.

RECOMMENDATION: Put all your Vim configuration stuff in the
$HOME/.vim/ directory ($HOME/vimfiles/ for MS-Windows). That makes it
easy to copy it to another system.

However, Vim will not create a vimrc file for you automatically, you will need to create it yourself. Example:

:!mkdir $HOME/vimfiles
:e $HOME/vimfiles/vimrc

I gather, from your interactions, that you can run vim. But want to create a vimrc file on Windows.

The easiest way is to follow the steps -

  1. run vim from any directory .. doesn't matter which directory.
  2. Then just do a save as ~\_vimrc. This is done by typing the character ":" and then :s ~\_vimrc <enter key> 3 This will save the current empty file in your HOME. Though the variable HOME is used in UNIX and even the ~ is a short for HOME.
  3. Note that a vimrc file is .vmrc in UNIX and _vimrc in windows.
  4. The equivalent vi file in UNIX is .exrc, and .vimrc for vim.

I had great trouble writing this out, and had to fix it 3 times. The colon brings up the command line on both vi and vim. Read about using vi and vim somewhere. The \ character needs escaping by typing the \ character twice. This is my first answer in 40 years on stack overflow. I am writing this on my windows laptop, sitting on my bed.

It depends on how you got vim on your computer.

I have a generic answer instead - create a vimrc file in your user's home directory, it's probably the "correct" answer as well.

Related