Vim Tips Wiki
(Adjust previous/next navigation)
(Change <tt> to <code>, perhaps also minor tweak.)
 
(4 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
|previous=937
 
|previous=937
 
|next=941
 
|next=941
|created=June 1, 2005
+
|created=2005
 
|complexity=basic
 
|complexity=basic
 
|author=Lee Savidge
 
|author=Lee Savidge
Line 12: Line 12:
 
|category2=
 
|category2=
 
}}
 
}}
I got really bored of editing multiple vimrc files when I wanted to change mine. So, after installing cygwin under Windows I added an environment variable which set HOME to be <tt>c:\cygwin\home\username</tt>. Vim/GVim in Windows reads that variable if it is set and notes that the config file to read is the one I have in my cygwin directory. Also, because Vim/GVim under Windows understands that the config files could be called either .vimrc or _vimrc it doesn't require any other change. Now when either Vim in cygwin or Vim/GVim in Windows loads, they both use the same config files. This assumes that your config files can work under either environment as mine do.
+
I got really bored of editing multiple vimrc files when I wanted to change mine. So, after installing cygwin under Windows I added an environment variable which set HOME to be <code>c:\cygwin\home\username</code>. Vim/GVim in Windows reads that variable if it is set and notes that the config file to read is the one I have in my cygwin directory. Also, because Vim/GVim under Windows understands that the config files could be called either .vimrc or _vimrc it doesn't require any other change. Now when either Vim in cygwin or Vim/GVim in Windows loads, they both use the same config files. This assumes that your config files can work under either environment as mine do.
   
 
==Comments==
 
==Comments==
Line 18: Line 18:
   
 
<pre>
 
<pre>
source c:/cygwin/home/username/_vimrc
 
 
set runtimepath+=c:/cygwin/home/username/.vim
 
set runtimepath+=c:/cygwin/home/username/.vim
 
source c:/cygwin/home/username/_vimrc
 
</pre>
 
</pre>
   
Line 32: Line 32:
   
 
and by this way, we can use the same vimrc. Don't forget we can use " if has('win32') ..." to write config for different environment.
 
and by this way, we can use the same vimrc. Don't forget we can use " if has('win32') ..." to write config for different environment.
  +
  +
----
  +
  +
Be careful with setting $HOME to something else under Windows. A lot of apps rely on such variable as well. You may end up messing up another app`s settings.
   
 
----
 
----

Latest revision as of 05:58, 13 July 2012

Tip 939 Printable Monobook Previous Next

created 2005 · complexity basic · author Lee Savidge · version 5.7


I got really bored of editing multiple vimrc files when I wanted to change mine. So, after installing cygwin under Windows I added an environment variable which set HOME to be c:\cygwin\home\username. Vim/GVim in Windows reads that variable if it is set and notes that the config file to read is the one I have in my cygwin directory. Also, because Vim/GVim under Windows understands that the config files could be called either .vimrc or _vimrc it doesn't require any other change. Now when either Vim in cygwin or Vim/GVim in Windows loads, they both use the same config files. This assumes that your config files can work under either environment as mine do.

Comments[]

Another option (if for some reason you don't want to change your Windows HOME var) is to create a vimrc file in your Windows home with the following lines:

set runtimepath+=c:/cygwin/home/username/.vim
source c:/cygwin/home/username/_vimrc

I think if you have installed cygwin, you can use the following method: under cygwin:

$ cd ~
$ ln -s /path/to/windows/_vimrc .vimrc

and by this way, we can use the same vimrc. Don't forget we can use " if has('win32') ..." to write config for different environment.


Be careful with setting $HOME to something else under Windows. A lot of apps rely on such variable as well. You may end up messing up another app`s settings.