This HowTo is based on Steve Hall's, with a few changes to reflect my own way of work. One significant difference is that I don't edit the Makefile. It covers two different free compilers: Borland BCC32 and cygwin gcc. Even when building with gcc, the method described does not require the Cygwin DLL to be available to run Vim. For other compilers (not tested by me), download the sources as in «Once per release
» below, and see the file INSTALLpc.txt in the "src" directory.
- Once and for all:
Make sure you have the required software tools and settings, as follows. They can use up a lot of disk, up to 300M or so for a full Cygwin installation, so be prepared.
- Once per release:
- This section assumes Vim 7.0. Change directory names (in the obvious way) for other versions.
- (Optional) Install the full distribution (runtime and binaries) from the "official" site. This is your "production" Vim (which you run to edit files), not your "development" one (which you compile).
- The Vim sources: Download the full Unix sources, even for Win32. For Vim 7.0, they are in the following places:
- Download these three archives anywhere convenient.
- "Prepare" the bz2 archive by running (in cygwin)
This uncompresses it, removes the .bz2 extension, and makes it understandable to WinZip.
- Using WinZip (or Cygwin gzip and tar), extract the three archives on top of each other into your d:\devel\vim (or whatever) directory. This creates a subdirectory "vim70" and puts evrything in or under it. [For the ".tar.gz" archives, WinZip will tell you that each of them contains only one further (.tar) archive and ask you if you want to unpack that at some temporary location and open it immediately. Answer "Yes" to that.]
- (Optional) Download Vince Negri's patch if you want to use one or more of the 'conceal', 'cursorbind' and :ownsyntax features.
- Every time:
- Note: I haven't tested all possible methods of getting the Vim bugfixes. The one described below works for me. There are (IIUC) three other methods:
A-A-P (which requires Python)
I don't know how to make them work, so don't ask me.
- For stable releases (7.0): Download any new patches from ftp://ftp.vim.org/pub/vim/patches/7.0/. (For unstable versions the sources may be elsewhere, usually somewhere under ftp://ftp.vim.org/pub/vim/unstable/.) Also download the latest version of the README file from the same place, it is the "table of contents" of the patches. Place all patches and their README in d:\devel\vim\vim70\patches\ (and create that directory if it doesn't exist). OTOH, if your browser or other ftp client asks permission to overwrite an existing README on your disk, click "Yes".
- In cygwin:
patch -p0 < patches/7.0.001
patch -p0 < patches/7.0.002
etc., for all new patches in ascending sequence. As you apply the patches, watch the filenames output by the patch program. For instance, if anything ending in ".vim" or ".txt" gets patched, you may want to copy (not move) the new version from the "development" hierarchy (starting at d:\devel\vim\vim70\runtime) to the "production" hierarchy (starting — in Cygwin parlance — at $VIM/vim70)
- If you applied patches to one or more helpfiles (i.e. runtime/doc/*.txt), then, after copying them to your "production" hierarchy (in $VIM/vim70/doc/) you will have to use the following Ex-command the next time you run (g)vim:
- For all versions: Have a look at the Makefile you are going to use (Make_bc5.mak for BCC32 or Make_cyg.mak for cygwin gcc). It is in the "src" subdirectory. Write down any non-standard option values you might need. Then add them in the form -Dname=value (for Borland make) or name=value (for cygwin make) on the following command-line. Here are the two commands I use to generate vim and gvim (or the ones I used when I had a Windows machine):
- For Borland make and BCC32 (in COMMAND.COM or CMD.EXE):
make -B -fMake_bc5.mak -DGUI=no vim
make -B -fMake_bc5.mak -DOLE=yes -DCPUNR=i686 vim
- For Cygwin make and gcc (in Cygwin bash):
make -B -f Make_cyg.mak GUI=no vim.exe
make -B -f Make_cyg.mak OLE=yes gvim.exe
- A trick: To log the output of the (Cygwin) make to a file and also watch it in real-time:
make -B -f Make_cyg.mak OLE=yes gvim.exe 2>&1 |tee gvim.log
-B (optional) forces a full rebuild from scratch regardless of modification dates. Without it, only modified modules will be recompiled.
GUI=no builds the console version.
OLE=yes builds a GUI with OLE support
CPUNR= (optional) defines the processor level. Admissible values for BCC are i386, i486, i586, i686, or 3, 4, 5, 6. For gcc, there are two variables (CPUNR and ARCH). In both cases, omitting it will assume i386, which should build an executable which works on all processors which can run Windows.
DEBUG=yes (optional) if you want to compile "with debugging information".
vim, vim.exe or gvim.exe is the "target". On BCC, "vim" means "build only the editor executable". On Cygwin, the exact executable name must be used. If you omit the target, Make uses a default target named "all", meaning "build the editor and all ancillary programs".
There are other options. Mostly the defaults are OK.
- Watch the action while compilation goes on...
- Don't panic if you see many warnings, especially in if_perl.c, if_ruby.c and if_tcl.c. As long as an executable is produced, there is a good chance that it will work.
- The programs you just compiled end up in the current (src) directory. If you omit the target, some ancillary programs are also compiled, they may end up in src/ (install, uninstal) or under it (gvimext, xxd).
- Run gvim from there. Issue the ":version" command and check its output. Maybe issue a few other commands to check that it works OK. If it does:
- (Optional) Rename %VIM%\vim70\gvim.exe and/or \vim.exe to something.else (e.g., gvim000.exe, vim000.exe).
- Copy your newly-compiled editor to the "production" hierarchy, at %vim%\vim70.
- That's all folks ! — as far as the binaries are concerned. The "official patches" usually do not affect the runtime files, even when there are changes to them. The latest versions of the runtime files are (or ought to be) in ftp://ftp.vim.org/pub/vim/runtime/ and its subdirectories. The README.txt in that same folder tells you how to use A-A-P (and where to obtain it) to get only the new versions (except the first time, of course). Or if you don't want A-A-P (or if you don't want Python, which is required by A-A-P), you can get the runtime files by plain old ftp — but in that case you will have to do the dirty work by hand. — Note: That pub/vim/runtime/ directory has a dos/ subdirectory which contains a duplicate copy of everything but with Dos ends-of-files. I recommend not to bother with those and to use everything except the files in or under runtime/dos/. Vim for Windows can cope with Unix-like ends-of-line anyway (if you leave the 'fileformats' option at its default "dos,unix" value) and Unix fileformat uses one less byte per line of text.