History
Article Edit this page Discussion

Use the same runtime files for native-Windows Vim and cygwin Vim

From Vim Tips Wiki

Jump to: navigation, search

Tip 973 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.

[edit] 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.


Rate this article:

Share this article:

Hubs Highlights International Sites Wikia messages
Entertainment
Gaming
Cartoons & Comics
Science Fiction
Hobbies
Sports
See all...
Grand Theft Auto
Pixar
Legend of Zelda Wiki
Terminator Wiki
Everquest II Wiki
Dark Shadows
German
Spanish
Chinese
Japanese
More...
Wikia is hiring for several open positions


Vote for collaboration of the month.

Send this article to a friend
"Use the same runtime files for native-Windows Vim and cygwin Vim"
 
 
Hi!

I thought you'd like this page from Wikia!

http://vim.wikia.com

Come check it out!
Send confirmation