Vim Tips Wiki
m (Added to Cygwin Category + minor reformatting)
(Move categories to tip template)
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  +
{{TipImported
{{review}}
 
{{Tip
 
 
|id=973
 
|id=973
  +
|previous=972
|title=Using native-Windows and cygwin versions of Vim with the same runtime files
 
  +
|next=974
|created=August 15, 2005 19:37
+
|created=August 15, 2005
 
|complexity=basic
 
|complexity=basic
  +
|author=[[User:Tonymec|Tony Mechelynck]]
|author=antoine.mechelynck--AT--skynet.be
 
 
|version=5.7
 
|version=5.7
 
|rating=13/6
 
|rating=13/6
  +
|category1=Cygwin
|text=
 
  +
|category2=
It is possible to keep native-Windows and Cygwin versions of Vim on a same machine with common runtime files (I have done it; but see [[VimTip972]] for an alternative solution) Here is what you need to do for that:
 
 
}}
 
It is possible to keep native-Windows and Cygwin versions of Vim on a same machine with common runtime files (I have done it; but see [[Run native-Windows Vim from cygwin without a wrapper]] for an alternative solution). Here is what you need to do for that:
   
1. Install the full Windows distribution in C:\Program Files\vim\vim## where ## is the version (e.g. 63 for Vim 6.3, or 70aa for Vim 7.00aa ALPHA).
+
'''1.''' Install the full Windows distribution in C:\Program Files\vim\vim## where ## is the version (e.g. 63 for Vim 6.3, or 70aa for Vim 7.00aa ALPHA).
   
2. Install the cygwin executables only (of the same version and sub-version; the patchlevel may be different), in /bin
+
'''2.''' Install the cygwin executables (of the same version and sub-version; the patchlevel may be different), in /bin; don't install the "cygwin runtime files".
   
-- repeat either step 1 or step 2 at each upgrade
+
Repeat either step 1 or step 2 at each upgrade.
   
3. Set VIM (in the Windows environment) to C:\Program Files\vim and HOME to your home directory
+
'''3.''' Set VIM (in the Windows environment) to C:\Program Files\vim and HOME to your home directory
   
4. In the cygwin startup files (e.g. ~/.bash_profile) add the following lines:
+
'''4.''' In the cygwin startup files (e.g. ~/.bash_profile) add the following lines:
export VIM=`cygpath -u $VIM`
 
export HOME=`cygpath -u $HOME`
 
   
  +
<pre>
5. All runtime files must be in Unix format. If they aren't, do the following in vim (version 7 or later) for native-Windows (it takes some time but it's fairly automatic). (On version 6 it's possible but since ** wildcards are not recognised it is more work.) (See also [[VimTip848]] about how to install several _different_ versions in parallel.)
 
 
export VIM=`cygpath -u $VIM`
:set nomore
 
 
export HOME=`cygpath -u $HOME`
:args $VIM/**/*.vim
 
  +
</pre>
:argdo setl ff=unix
 
:args $VIM/**/*.txt
 
:argdo setl modifiable noro ff=unix
 
:set more
 
   
 
'''5.''' All runtime files must be in Unix format. If they aren't, do the following in vim (version 7 or later) for native-Windows (it takes some time but it's fairly automatic). (On version 6 it's possible but since ** wildcards are not recognised it is more work.) (See also [[Installing several releases in parallel, even with matchit]] about how to install several _different_ versions in parallel.)
6. Directories $HOME/vimfiles and $HOME/.vim must be made identical. This can be done in Cygwin bash with the following command:
 
cd ~
 
ln -s vimfiles .vim
 
   
  +
<pre>
-- steps 3 to 6 need be done only once, they remain valid even if you later install a different version.
 
 
:set nomore
}}
 
 
:args $VIM/**/*.vim
 
:argdo setl ff=unix
 
:args $VIM/**/*.txt
 
:argdo setl modifiable noro ff=unix
 
:set more
  +
</pre>
  +
 
'''6.''' Directories $HOME/vimfiles and $HOME/.vim must be made identical. This can be done in Cygwin bash with the following command:
  +
  +
<pre>
 
cd ~
 
ln -s vimfiles .vim
  +
</pre>
  +
 
Steps 3 to 6 need be done only once, they remain valid even if you later install a different version.
  +
 
==Comments==
 
Note: Cygwin is a "Unix-like" OS, Windows is a "Dos-like" OS. With the above tip, you will use a common _vimrc (and common user plugins) for both. Any differences can be resolved by using
  +
  +
<pre>
 
if has("unix")
 
" cygwin-specific code
 
else
 
" native-windows-specific code
 
endif
  +
</pre>
   
 
or even (e.g. if, in addition to this, you use dual-boot)
== Comments ==
 
Note: Cygwin is a "Unix-like" OS, Windows is a "Dos-like" OS. With the above tip, you will use a common _vimrc (and common user plugins) for both. Any differences can be resolved by using
 
if has("unix")
 
" cygwin-specific code
 
else
 
" native-windows-specific code
 
endif
 
   
  +
<pre>
or even (e.g. if, in addition to this, you use dual-boot)
 
if has("unix")
+
if has("unix")
" code common to Cygwin and Linux
+
" code common to Cygwin and Linux
if has("win32unix")
+
if has("win32unix")
" code for Cygwin but not Linux
+
" code for Cygwin but not Linux
else
+
else
" code for Linux but not Cygwin
+
" code for Linux but not Cygwin
endif
+
endif
elseif has("win32")
+
elseif has("win32")
" code for windows-native Vim
+
" code for windows-native Vim
else
+
else
echoerr "Unknown OS"
+
echoerr "Unknown OS"
endif
+
endif
  +
</pre>
   
See ":help has()" and "[http://vimplugin.sf.net/cgi-bin/help?tag={{urlencode:feature-list}} :help feature-list]" for more examples
+
See {{help|has()}} and {{help|feature-list}} for more examples.
   
antoine.mechelynck--AT--skynet.be
 
, August 15, 2005 19:54
 
 
----
 
----
<!-- parsed by vimtips.py in 0.470436 seconds-->
 
[[Category:Cygwin]]
 

Latest revision as of 05:06, 25 April 2008

Tip 973 Printable Monobook Previous Next

created August 15, 2005 · complexity basic · author Tony Mechelynck · version 5.7


It is possible to keep native-Windows and Cygwin versions of Vim on a same machine with common runtime files (I have done it; but see Run native-Windows Vim from cygwin without a wrapper for an alternative solution). Here is what you need to do for that:

1. Install the full Windows distribution in C:\Program Files\vim\vim## where ## is the version (e.g. 63 for Vim 6.3, or 70aa for Vim 7.00aa ALPHA).

2. Install the cygwin executables (of the same version and sub-version; the patchlevel may be different), in /bin; don't install the "cygwin runtime files".

Repeat either step 1 or step 2 at each upgrade.

3. Set VIM (in the Windows environment) to C:\Program Files\vim and HOME to your home directory

4. In the cygwin startup files (e.g. ~/.bash_profile) add the following lines:

export VIM=`cygpath -u $VIM`
export HOME=`cygpath -u $HOME`

5. All runtime files must be in Unix format. If they aren't, do the following in vim (version 7 or later) for native-Windows (it takes some time but it's fairly automatic). (On version 6 it's possible but since ** wildcards are not recognised it is more work.) (See also Installing several releases in parallel, even with matchit about how to install several _different_ versions in parallel.)

:set nomore
:args $VIM/**/*.vim
:argdo setl ff=unix
:args $VIM/**/*.txt
:argdo setl modifiable noro ff=unix
:set more

6. Directories $HOME/vimfiles and $HOME/.vim must be made identical. This can be done in Cygwin bash with the following command:

cd ~
ln -s vimfiles .vim

Steps 3 to 6 need be done only once, they remain valid even if you later install a different version.

Comments[]

Note: Cygwin is a "Unix-like" OS, Windows is a "Dos-like" OS. With the above tip, you will use a common _vimrc (and common user plugins) for both. Any differences can be resolved by using

if has("unix")
  " cygwin-specific code
else
  " native-windows-specific code
endif

or even (e.g. if, in addition to this, you use dual-boot)

if has("unix")
  " code common to Cygwin and Linux
  if has("win32unix")
    " code for Cygwin but not Linux
  else
    " code for Linux but not Cygwin
  endif
elseif has("win32")
  " code for windows-native Vim
else
  echoerr "Unknown OS"
endif

See :help has() and :help feature-list for more examples.