3

I am using MacVim at home and using gvim in Windows at work. Since I use git to sync my vim settings, I want the settings to be in the same folder named vimfiles. I set runtimepath in my .gvimrc like this:

set runtimepath=~/vimfiles/,$VIMRUNTIME

but the plugins in ~/vimfiles/plugin seems not been loaded by MacVim. Am I doing something wrong with it?

Is it because the subfolders in vimfiles were not recursively added to runtimepath?

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
treblam
  • 265
  • 4
  • 14

4 Answers4

11

I'm not sure why you are worried about forcing Vim on MacOS to understand Window's file-naming convention, when Vim can do the right thing and use the standard '.' naming on Windows too. You're going against the flow.

This is from the Vim wiki:

One helpful Vim setting in a mixed-OS environment is to use .vim for Vim user settings also for Windows systems (Vim automatically picks up a .vimrc config file instead of _vimrc by default). The following snippet in .vimrc will do the trick, and thus allow you to synchronize without directory renaming:

" On Windows, also use '.vim' instead of 'vimfiles'; this makes synchronization " across (heterogeneous) systems easier.

if has('win32') || has('win64')
  set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
endif

That's what I did on my WinXP machine at work, and I synchronize between my Mac, XP and about five Linux hosts by copying a tarball across.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
6

Just make ~/.vim a symbolic link to your ~/vimfiles directory and it should work beautifully.

gotgenes
  • 38,661
  • 28
  • 100
  • 128
  • thanks very much,you solved my problem.But I still want to know why set runtimepath doesn't work. – treblam Mar 26 '11 at 04:14
2

According to the :h initialization, loading plugin scripts (search for ^4\.) is done before GUI-specific initializations are performed (search for ^8\.), so you should place this line into ~/.vimrc, not into ~/.gvimrc.

ZyX
  • 52,536
  • 7
  • 114
  • 135
  • thanks for your answer,I tried to rename .gvimrc to .vimrc just now,still not work,I even tried to set it like this in .vimrc:"set runtimepath=~/vimfiles/,~/vimfiles/plugin,$VIMRUNTIME",with no luck,very strange. – treblam Mar 26 '11 at 13:02
  • @treblam You should not add `~/vimfiles/plugin` to rtp. What do `:scriptnames` show? Maybe for some reason (like a shell alias that adds `-u NONE`) vimrc is not loaded at all? Does explicit loading of plugins (`runtime! plugin/**/*.vim`) in the current session work? – ZyX Mar 26 '11 at 13:14
  • It is my fault,the snipmate plugin has a problem which make me think all the plugins are still not been loaded,the result of `:scriptnames` shows they are loaded now,thanks very much. – treblam Mar 26 '11 at 13:35
0

Did you try set runtimepath+=/path/to/vimfiles (note the +=)? Also it's possible that you need to do that for all the subfolders.

Since you are using Git, you may set the working directory to ~/.vim on the Mac and whatever it is on the Windows machine making the name of the folder irrelevant.

$ git config worktree /Users/username/.vim

I use DropBox to sync my ~/.vim folders on all my machines (Mac@work, Mac@home, Ubuntu@home and a Linode VPS somewhere). All the autoload, bundle, etc. folders are in a DOTFILES/vim subfolder of my DropBox and symlinked to ~/.vim/autoload, ~/.vim/bundle, ~/.vim/syntax, etc.

Simply symlinking ~/Dropbox/DOTFILES/vim to ~/.vim would work, too, but I wanted to keep the ability to have things specific to a machine stay on this machine. Views, for example.

My .vimrc contains only these few lines:

source ~/Dropbox/DOTFILES/vimrc

" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :tabnew ~/Dropbox/DOTFILES/vimrc<CR>
nmap <silent> <leader>sv :so ~/Dropbox/DOTFILES/vimrc<CR>

Setting it up on a new machine would take 2 or 3 minutes max, I guess, and keeping the whole thing up to date is totally effortless.

romainl
  • 186,200
  • 21
  • 280
  • 313