Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim settings file on Windows

Tags:

vim

windows-7

I can't believe I am typing a question for a simple thing like this but here we are. I can't for the life of me figure out what the exact name for the settings file is for vim on Windows (.vimrc does not work on Windows). And if I have names right (read the next para) then I don't know why it is not picking up the settings from it.

I tried creating _vimrc and _gvimrc in the root directory where I copied the file from the example settings file that came installed with vim. I set the following command on top of the example commands:

set nobackup set nowritebackup set guifont=Courier_New:h11:cANSI 

It is not accepting this file (whether it is named _vimrc or _gvimrc, I tried both) as the settings file as the font has not changed on the next start-up and still writes backup files.

like image 527
Samaursa Avatar asked Feb 02 '12 21:02

Samaursa


People also ask

Where is Vim config file in Windows?

On Windows, when you start Vim normally, it *either* runs the file "C:\Documents and Settings\(user name)\_vimrc" (where "(user name)" is replaced by the actual user name); *or*, if that file doesn't exist (it usually doesn't, for most users), it runs the file "C:\Program Files\vim\_vimrc".

How do I access Vim settings?

In the terminal, type vi . vimrc . This will create an empty vimrc system file which you want to use. In the file, type set number , and then hit Esc on the keyboard and type in :wq .

Where is the vimrc file on Windows 10?

It may be under [Your Installation Directory]/Vim/ . In my case, the _vimrc file is under C:/Program Files (x86)/Vim/ . Because C:/Program Files (x86)/Vim was the default installation directory when I installed Vim on Windows 10 from the executable installer available at https://www.vim.org/download.php.


2 Answers

my _vimrc/_gvimrc is stored at C:/Users/<ME>/_vimrc and is working fine.

It's generally a good idea to keep personal settings separate from installation files.

To get more information about the search paths for your configuration files, type :he vimrc-intro.

And be careful: the docs say

For MS-DOS and MS-Windows you can use one of these:
$HOME/_vimrc
$VIM/_vimrc

While this is absolutely true, it could be a bit surprising that $VIM does not expand to e.g. C:/Program Files/vim/<your_version> (this is what $VIMRUNTIME holds) but only to C:/Program Files/vim/.

This said, C:/Program Files/vim/_vimrc should be read during startup.

like image 163
eckes Avatar answered Sep 21 '22 10:09

eckes


Why not just edit the vimrc file in vim itself and figure it out its name?. Using the following command.

:e $MYVIMRC 

As ghiscoding mentions in a comment, you may need to run Vim as an administrator to be able to save your changes.

like image 27
suhair Avatar answered Sep 21 '22 10:09

suhair