Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created July 18, 2013 · complexity basic · author Gennaro.prota · version 7.0

To share your vimrc file between all of your systems and environments, you have at least a couple of options.

Option 1: use :sourceEdit

By using the :source command, you can put your vimrc file and all its dependencies in a common directory (preferably under version control) and source those common files from each vimrc that needs them. In fact, you'll very likely just source one of them (the "main" one) and that will, in turn, source others.

For instance, the vimrc file in your Windows home will look something like:

source X:/path/to/common/dot-files/vim/my_vim.vim

Other systems need an equivalent of the above, using the system's file naming conventions. Cygwin, in particular, may have problems with DOS-style paths, so you are probably better off with Option 2, below.

Option 2: use symbolic linksEdit

Once you have the common files available somewhere you can make each .vimrc that you need be actually a symbolic link to the common .vimrc "main" file (see above). Under Unix and Cygwin:

$ cd ~
$ ln -s /path/to/common/dot-files/vim/my_vim.vim .vimrc

Do not forget that you can use has() and exists() to cope with the different capabilities offered by the various Vim builds and distributions.


Community content is available under CC-BY-SA unless otherwise noted.