How can I tell vim where my _vimrc and plugins are

2019-09-08 14:34发布

问题:

At work I have gvim installed in C:/Program Files/vim but have no write permission on this folder. I would like vim to use my personal _vimrc and potentially some addins that would be in a bundle directory. Problem is that vim choose the default _vimrc in C:/...

What can I do to fix my problem, I was thinking of a script but I can't manage in writing one that work... ?

EDIT: Off course I do not have admin rights

回答1:

Your configuration belongs in %HOME% (or %USERPROFILE% if the former isn't set). You can always override that by setting the %MYVIMRC% environment variable (e.g. in the Windows Control Panel under Advanced System Settings) passing a different configuration script via -u path/to/vimrc. (Defining %VIMINIT% should work, too, but I didn't get it to work on Windows.) See :help startup for details.



回答2:

The first place Vim looks for initializations (see :h .vimrc) is in your home directory. (If you're not sure where this is, you can use echo %HOMEPATH% from the command prompt to find out.)



回答3:

Vim will use the _vimrc in your home directory if it exists, so you could just copy it there (%userprofile%_vimrc), or you could set the environment variable $VIM to the directory of your choice. You can set an environment variable on Windows by right-clicking on My Computer -> Properties -> Advanced System Settings. For more info see the vim docs.