2. Preparation

In order to compile Vim, you need three things: a compiler, the Vim source code, and utilities to get and extract the source code. Optionally, you may need to install extra programs to enable certain interfaces in Vim (such as Vim's built-in Perl or Python support).

Vim's source code is available through three different methods: FTP, CVS, and A-A-P. The simplest method is probably CVS, which requires only a CVS client utility in addition to the compiler.

The prepatched source code is available via CVS at http://cvs.vim.org . The CVS archive is manually updated by a volunteer as new patches are released, so it may briefly lag behind the currently released patches, but usually no more than a day or two. Check out the code using your preferred CVS client, then simply update your local archive as new patches come out so that you can always have the latest version.

You will only need a CVS client to get your source this way. You can get a command line CVS client as part of the Cygwin tools or from the msys-DTK package with the MinGW tools. Alternatively, you can get WinCVS, a native Win32 GUI application, from www.wincvs.org.

The command to initially checkout the code is:
C:\TEMP>cvs -z3 -d :pserver:anonymous@cvs.vim.sourceforge.net:/cvsroot/vim co vim
No password is required, so if you are prompted for one, just hit enter. The code will be downloaded from the CVS server and placed in a vim/ subdirectory of your current directory. The -z3 option will compress the files during transit.


If you are unable to access the above site due to firewall / proxy problems, you can try the command
C:\TEMP>cvs -z3 -d :pserver:anonymous@cvs-pserver.sf.net:80/cvsroot/vim co vim
which will attempt the download via port 80, which most firewalls will allow through, since it is the standard HTTP port.

After the initial checkout, you can keep your archive updated by changing to the vim subdirectory and issuing the command:
C:\TEMP\Vim>cvs -z3 update -Pd
The update command will pull down any files modified since your last checkout / update. The -d flag will cause any new directories created on the CVS server since the last checkout / update to be created locally as well. The -P flag will remove any directories that are made empty by the current update. Similar instructions can be found at http://www.vim.org/cvs.php , including links to other CVS guides and information.

This manual process requires that you download all the archives, extract them, patch them, and compile them yourself. You need various additional utilities and time. When using this method, it is a good idea to create some batch files to save a lot of retyping and to script tedious commands (like applying the individual patches. Vim 6.1 had 474 of them).

The most up-to-date code is available via ftp from ftp.vim.org and its mirrors ftp.xx.vim.org, where xx is replaced with a country code like us, ca, or uk. See http://www.vim.org/mirrors.php for a more complete list of mirror sites. The /pub/vim/pc directory has the DOS-formatted source code in zip archives. You will want the vim62src.zip, vim62lang.zip and either the vim62rt.zip or the vim62rt1.zip and vim62rt2.zip files. Alternatively, you can get the UNIX-formatted, gzipped or bzipped tarballs from /pub/vim/unix (either vim-6.2.tar.bz2 or all four of vim-6.2-rt1.tar.gz, vim-6.2-rt2.tar.gz, vim-6.2-src1.tar.gz, and vim-6.2-src2.tar.gz) and /pub/vim/extra (vim-6.2-lang.tar.gz and vim-6.2-extra.tar.gz).

To extract the source from these archives, you will need several utilities. For the zip archives, you will need an unzip program. For the tar archives, you will need a tar program, a gunzip program, and perhaps a bunzip2 program. These utilities are available with the Cygwin distribution or in the MSYS package of the MinGW distribution. Finally, you can get the individual executables from sites like http://unxutils.sf.net or http://gnuwin32.sf.net . If you prefer a GUI program, you can get WinZip (which handles zip, tar, and gzip) from http://www.winzip.com or 7-Zip (which handles zip, tar, gzip, and bzip2) from http://www.7-zip.org.

Whichever source archives you get, place them in the C:\TEMP directory together. These archives hold the base 6.2.0 code. Extract the files into the current directory. If you are using the zip archives, you will have a new vim subdirectory, and the source will be located in C:\TEMP\vim\vim62\src; otherwise, with the tar archives, you will have a vim62 subdirectory, and the source will be located in C:\TEMP\vim62\src.

To get the latest version of Vim, you must apply all the patches from the /pub/vim/patches directory for the version of Vim you are compiling. Download all the files starting with 6.2 and place them in the C:\TEMP directory with the source archive files. To save some downloading time, every one hundred patches are combined into a single patch file that you can get instead of the one hundred individual patches. If available, they will have filenames like 6.2.1-100 and 6.2.101-200. You will still have to get the remaining patches individually. For reference, the README file in the /pub/vim/patches directory gives a quick synopsis of the bug or feature addressed by each patch, and the header of each patch gives a more complete description of the bug, the way the bug was fixed, and a list of the files affected by the patch.

Some patches address other operating system ports and are not needed by the Win32 version. If you got your source from the tar archives, this is not a problem, because all the source files for all operating systems will be present and get patched, even if they aren't used in the compile. If you got your source from the zip archives, some extra preparation is required.

Files not needed in a Win32 compile are not included in the zip archives. If you try to apply a patch for one of these missing files, you will get a 'File not found' error which can be safely ignored. Some patches, though, patch files in the 'runtime' directory, which doesn't exist in the zip archives. You will get 'File not found' errors for these files as well, but instead of ignoring it, you will want to specify the path to the file. Fortunately, this is as easy as specifying the path it just tried, but leaving off the 'runtime/' part. If you want to avoid retyping a lot of things, you can edit the patch files manually and remove the 'runtime/' from the path. For example, if you have an older version of Vim already installed, you could do:
C:\TEMP>vim -c "set lz" -c "bufdo! %s#--- runtime/#--- # | w" -c q 6.2.*
to open all the patch files in Vim and loop through each one, removing the 'runtime/' path from the 'to be patched' file specification.

You will need the patch program to apply the patches. Then, simply change to the vim62 directory (of which src and runtime are subdirectories) and issue the command
C:\TEMP\vim62>patch -p0 < ../6.2.001
or, if you have a more recent version of GNU patch,
C:\TEMP\vim62>patch -p0 -i ../6.2.001

This process is then repeated for each patch in order, since some later patches are dependent on earlier patches. To apply all the patches at once, it would be a good idea to combine all the individual patches into a single large patch and apply them all at once. For example:
C:\TEMP>copy 6.2.* 6.2-all.patch
C:\TEMP>cd vim62
C:\TEMP\vim62>patch -p0 < ../6.2-all.patch

The newest way to get the latest source is with the A-A-P project created by Vim's author, Bram Moolenaar. The project is currently in the alpha stage, so all usual warnings apply. Install the necessary files by follwing the instructions at http://www.a-a-p.org/download.html . We will assume that the program is installed into C:\Exec. Since it is a Python application, you will also need a working Python distribution (2.2.x recommended). The program currently runs well with Cygwin's Python, and will run well with ActiveState's Python if you use A-A-P version 0.138 or greater.

Once you have an operational A-A-P installation, download the Vim recipe from http://www.a-a-p.org/vim/main.aap and place it into the directory where you want to build Vim. From a command line in that directory run the aap program with the command
C:\TEMP>python C:\Exec\main.py fetch
By default, this will extract the source from CVS. Running the program with the command
C:\TEMP>python C:\Exec\main.py fetch CVS=no
will instead automatically download all the source archives and patches from the FTP site, expand the source, and apply the patches.

As new patches are released, you can run the command again to update your sources from the CVS archive or download and apply them from FTP. Only the new and modified files will be retrieved on the subsequent updates.

More instructions can be found at http://www.a-a-p.org/ports.html Note that running aap with no arguments will download and compile the sources, but it currently uses the Unix configure and Makefile, which won't work for building a Win32 application, so you will only want to use aap with the 'fetch' option for now.

Vim can interface with several external libraries to extend its editing functionality. For example, Perl and Python support can be used to enhance Vim's scripting capabilities. The Iconv and Gettext libraries can be used to improve multilingual support. In order to use these features, support for them must be enabled at compile time. Also, the appropriate headers and libraries must be available. Self-installing binary distributions are available for almost all the libraries Vim can use, and installing them will also install the necessary development files Vim requires.

Below is a list of the external libraries which Vim can use, where to get them, and what extra features they provide. Not addressed is how to use the extra features; help on that subject can be found in Vim's help files.

Vim can work with four external scripting engines to supplement its own built-in scripting language.

Vim can work with Perl versions 5.004 through 5.8. You can download a binary distribution of the latest Perl release from http://www.activestate.com/activeperl and install it on your system. With a Perl-enabled Vim, you can use the :perl and :perldo commands to execute Perl functions. Read :help perl and especially :help perl-using for a description of the Vim's interface with Perl.

Vim can work with Python 1.5 through 2.2.2. You can download a binary distribution of the latest Python release from http://www.activestate.com/activepython and install it on your system. With a Python-enabled Vim, you can use the :python and :pyfile commands to execute Python functions. Read :help python and especially :help python-vim for a description of Vim's interface with Python.

Vim can work with Ruby 1.6.x. You can download a binary distribution of the latest Ruby release from http://rubyinstaller.sourceforge.net and install it on your system. With a Ruby-enabled Vim, you can use the :ruby, :rubyfile, and :rubydo commands to execute Ruby functions. Read :help ruby and especially :help ruby-vim for a description of Vim's interface with Ruby.

Vim can work with Tcl 8.x. You can download a binary distribution of the latest Tcl release from http://www.activestate.com/activetcl and install it on your system. With a Tcl-enabled Vim, you can use the :tcl, :tclfile, and :tcldo commands to execute Tcl functions. Read :help tcl and especially :help tcl-commands for a description of Vim's interface with Tcl.

Vim can also utilize libraries to improve its support for character encodings and different languages. Technically, you do not need them preinstalled in order to compile Vim, but they must be present in your PATH or in your vim install directory to enable their features in Vim.

Locale and multi-language support can be enabled in Vim with the gettext library. With gettext, messages and menus will appear in the language specified by the user's locale. You can get a copy of the gettext library for Win32 from http://sourceforge.net/projects/gettext See :help multilang for more information.


If you have already installed Vim with the self-extracting installer from ftp://ftp.vim.org/pub/vim/pc/gvim62.exe then you already have libintl.dll in your vim\vim62 install directory and do not need to download it again.