Where can I find vimrc file in Windows?
Asked Answered
W

6

11

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 ?

Wombat answered 30/3, 2020 at 13:18 Comment(0)
W
10

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
Wetzell answered 30/3, 2020 at 14:28 Comment(0)
S
3

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.

Subordinate answered 18/6, 2022 at 13:49 Comment(0)
M
3

Go to C:\Users\<Your-Username> and create .vimrc file with this command:

vim .vimrc

simple .vimrc config:

filetype plugin indent on
set autoindent
syntax on
set number
Meshach answered 22/7, 2023 at 20:49 Comment(0)
G
2

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.

Gamboge answered 30/3, 2020 at 13:21 Comment(4)
I don't how to create one such fileWombat
in Vim, type: :w path/to/filename. For instance, :w ~/vimrc.Gamboge
Sorry, I don't get what you're saying . I'm new to this command interface. Could you please elaborate?Wombat
The "vimrc" file is not needed to use vim. When you learn how to create files using vim, come back to this answer and create the "vimrc" file in your home directory. No command line interface required. There are other ways to create files on Windows, if you prefer.Gamboge
H
0

The question is "Where can I find vimrc file in Windows?" which was only answered in the generic (aka default) sense. But the specific answer for any given user is:

That will report, for example,

system menu file: "$VIMRUNTIME\menu.vim"

system vimrc file: "$VIM\vimrc"

 user vimrc file: "$HOME\_vimrc"

2nd user vimrc file: "$HOME\vimfiles\vimrc"

3rd user vimrc file: "$VIM_vimrc"

  user exrc file: "$HOME\_exrc"

2nd user exrc file: "$VIM_exrc"

system gvimrc file: "$VIM\gvimrc"

user gvimrc file: "$HOME\_gvimrc"

2nd user gvimrc file: "$HOME\vimfiles\gvimrc"

3rd user gvimrc file: "$VIM_gvimrc"

   defaults file: "$VIMRUNTIME\defaults.vim"

system menu file: "$VIMRUNTIME\menu.vim"

In addition, these will report exactly what directories are the default: :echo $VIM

:echo $HOME

:echo $VIMRUNTIME

etc.

Harpp answered 26/10, 2022 at 2:39 Comment(0)
S
0

Create / copy your _vimrc file to your user profile folder. Usually in C:\Users\<username>, or exactly in %USERPROFILE%\_vimrc:

In my case:

C:\Users\martin>set USERPROFILE
USERPROFILE=C:\Users\martin

C:\Users\martin>notepad %USERPROFILE%\_vimrc
Socialite answered 26/6 at 5:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.