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 ?
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 -
- run vim from any directory .. doesn't matter which directory.
- 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.
- Note that a vimrc file is .vmrc in UNIX and _vimrc in windows.
- 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.
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
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.
:w path/to/filename
. For instance, :w ~/vimrc
. –
Gamboge 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.
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
© 2022 - 2024 — McMap. All rights reserved.