8

One of vim's more often used configurations is having a folder structure like this

\[vimfiles]
\[vim73]
\_vimrc

How can I start vim with _vimrc and [vimfiles] being in some other folder? The folder in question in not one of those which vim upon starting checks automatically?

Rook
  • 60,248
  • 49
  • 165
  • 242
  • Related: http://stackoverflow.com/questions/16903936/howto-change-location-of-vimrc-and-vim/16907192#16907192 – FDinoff Jul 20 '13 at 17:49

3 Answers3

5

You can pass a custom location for the ~/.vimrc file; :help startup has all the details. For example, you could pass a file location via -u, or define a :source file command in the environment variable VIMINIT.

Once you're running your own vimrc file, the loading of plugins is determined by the 'runtimepath' option. Therefore, if you want to use a non-default location (not ~/.vim / ~/vimfiles), just :set runtimepath=... to it.

Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324
4

This is how I do it: https://github.com/mihaifm/vimfiles

Let's say you have Vim installed in E:\Vim and you want to load your vimfiles from D:\Dropbox\vimfiles

Edit your E:\Vim\_vimrc like this:

set rtp+=D:\Dropbox\vimfiles
source D:\Dropbox\vimfiles\_vimrc

Alternatively you can create symbolic links with the mklink and junction tools.

mihai
  • 37,072
  • 9
  • 60
  • 86
0
  1. Suppose the new path will be C:\Config\Username\Vim;

  2. Create a user environment variable VIMINIT and set it to source C:\Config\Username\Vim\_viminit;

  3. Create C:\Config\Username\Vim\_viminit and add source C:/Config/Username/_vimrc to it;

  4. Create that _vimrc and add set runtimepath+=C:/Config/Username/Vim/vimfiles to it;

  5. (optional) Create C:\Config\Username\Vim\_gvimrc for GUI specific settings and add the following at the end of _vimrc in order to load it at startup:

    if has("gui_running")
      source C:/Config/Username/Vim/_gvimrc
    endif
    
  6. (optional) Add set viminfo+=nC:/Config/Username/Vim/_viminfo to _vimrc in order to also store the viminfo file in the custom location.

Shamaoke
  • 6,222
  • 8
  • 34
  • 40