Wikia

Vim Tips Wiki

Changes: Use (and maintain) a single set of configuration files

Edit

Back to page

(My first article here. It began by editing Tip 939 in order to remove any advice to mess up with the HOME var. But then, this doesn't just concern Windows and Cygwin, so I felt having a new entry was appropriate.)
 
(Insert TipProposed template + manual clean)
 
Line 1: Line 1:
  +
{{TipProposed
  +
|id=0
  +
|previous=0
  +
|next=0
  +
|created=July 18, 2013
  +
|complexity=basic
  +
|author=Gennaro.prota
  +
|version=7.0
  +
|subpage=/2013
  +
|category1=
  +
|category2=
  +
}}
 
To share your [[vimrc]] file between all of your systems and environments, you have at least a couple of options.
 
To share your [[vimrc]] file between all of your systems and environments, you have at least a couple of options.
   
==Option 1 (use the <code>:source</code> command)==
+
==Option 1: use <code>:source</code>==
 
 
By using the <code>:source</code> 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.
 
By using the <code>:source</code> 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:
 
For instance, the vimrc file in your Windows home will look something like:
 
 
<pre>
 
<pre>
 
source X:/path/to/common/dot-files/vim/my_vim.vim
 
source X:/path/to/common/dot-files/vim/my_vim.vim
 
</pre>
 
</pre>
   
For other systems, you'd have the moral equivalent of the above, using the system's file naming conventions (Note: Cygwin, in particular, may have problems with DOS-style paths, so you are probably better off with Option 2, below).
+
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 (symbolic link)==
 
   
  +
==Option 2: use symbolic links==
 
Once you have the common files available somewhere you can make each <code>.vimrc</code> that you need be actually a symbolic link to the common <code>.vimrc</code> "main" file (see above). Under Unix and Cygwin:
 
Once you have the common files available somewhere you can make each <code>.vimrc</code> that you need be actually a symbolic link to the common <code>.vimrc</code> "main" file (see above). Under Unix and Cygwin:
 
 
<pre>
 
<pre>
 
$ cd ~
 
$ cd ~
Line 20: Line 31:
   
 
Do not forget that you can use <code>has()</code> and <code>exists()</code> to cope with the different capabilities offered by the various Vim builds and distributions.
 
Do not forget that you can use <code>has()</code> and <code>exists()</code> to cope with the different capabilities offered by the various Vim builds and distributions.
  +
  +
==Comments==

Latest revision as of 10:40, January 31, 2014

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.

CommentsEdit

Around Wikia's network

Random Wiki