The version of Python against which Vim was compiled must match the installed Python version, that is the Python DLL name, such as "python27.dll".

There are two somewhat incompatible Python versions: Python 2 and Python 3. They are invoked with different Vim commands: python/py and python3/py3. Some Vim plugins may target Python 2 and others Python 3. Ideally, Vim should be compiled with support for both Python 2 and Python 3.

You may not need this tip because the two main Windows installers for Vim usually already have Python support. The most up-to-date Vim version is available from http://sourceforge.net/projects/cream/files/ (Vim without Cream). You may find this tip useful if you want to compile your own Vim on Windows if, for example, you need Vim for a different version of Python.

Contents

Vim version 7.3.x or 7.4.x is already installed. We only want to replace files gvim.exe and vim.exe.

Python 2.x and Python 3.x are installed. Let's assume Python 2.7 is installed in C:/Python27 and Python 3.3 is installed in C:/Python33. The official Python installers from http://www.python.org place the DLL files (python27.dll and python33.dll) in the system path, usually C:\Windows\system32 or C:\Windows\SysWOW64.

These instructions are for compiling 32-bit Vim. Python must be 32-bit.

Download and run automated MinGW installer from https://sourceforge.net/project/showfiles.php?group_id=2435
The "base" package should be enough (we only need C compiler). Choose install directory without spaces in its path.
(NOTE: There are problems with the current MinGW installer, mingw-get-setup.exe, as of Oct 14, 2013.)

Get Vim source files from one of the links below. The source version should match your currently installed Vim version.

https://github.com/b4winckler/vim This is a git clone of Vim's official Mercurial repository. This may be the easiest way to get the most recent Vim source with all patches included, because you can download snapshots with a web browser without installing any other software. Google Code holds the official Vim repository but does not offer this feature.

Create a batch file build_vim.bat with the following content. It will build gvim.exe and vim.exe with Python 2.7 and Python 3.3 support, HUGE feature set, no OLE.
You can remove options PYTHON3, PYTHON3_VER, DYNAMIC_PYTHON3 if you need only Python 2.7.

Run the batch file. It will build files "gvim.exe" and "vim.exe" and move them into the folder of the batch file. The build process can take a few minutes. A log file will also be created. Any errors will appear in the console window.

Shut down all instances of Vim. Navigate to Vim program folder: C:\Programs\Vim\vim73 or similar. Back up the original gvim.exe and vim.exe: either rename them to gvim_original.exe, vim_original.exe or move them to another folder.

Copy the new gvim.exe and vim.exe files to the Vim program folder (by copying the files, the default permissions of the folder should be applied to the copies). Start Vim and see if it works:

Is the following correct: "The official Python installer ... puts python25.dll in %windir%/system32"? Perhaps that is an install option? I have installed Python several times and do not recall it dumping stuff in system32.

There should be a "clean" option in the makefile that can be used, rather than the advice to delete certain directories (and pathdef.c is in the deleted directory so need to mention it).

It is not really useful to build Vim without getting the current patches. The correct (and very easy) procedure now is to use the Mercurial repository set up by Bram to hold all the patched source and runtime files. We need documentation on how to do this.

Using a suitable build from Vim-without-Cream is definitely the best approach for 99% of Windows users. Some hunting around would probably find a version with an old version of Python if required (it would have an older Vim, although one that would be newer than 7.2 with no patches).

What is the github stuff? Björn Winckler is a well known Vimmer, but the github is an unofficial clone of the official release available via Mercurial, so I don't see why it would be listed first. Also, some explanation is needed: the tip says to select the Vim version via "Switch Tags" but is that really the Vim version? JohnBeckett 10:13, April 4, 2011 (UTC)

The GitHub mirror looks like the easiest way to download the most recent Vim source with all patches included, as well as any previous 7.x version. Only a web browser is needed. I assume that each tagged snapshot corresponds to Vim 7.x with indicated patches applied, but I cannot prove it. Getting the source from the official Mercurial repo requires installing Hg and figuring out how to use it. (I got the minimum, portable, CLI-only version and it takes up >17MB.) The Gettig_the_Vim_source_with_Mercurial tip is too much for someone who just wants to download the source and is not interested in Mercurial. And it says examples are for Linux. Vlad.irnov 18:42, April 4, 2011 (UTC)

There are problems with mingw32-make.exe -f Make_ming.mak clean. There are errors because it tries to delete files that do not exist. And it does not finish the job and leaves some directories.Vlad.irnov (talk) 11:07, May 1, 2013 (UTC)