Vim Tips Wiki
No edit summary
(13 intermediate revisions by 8 users not shown)
Line 11: Line 11:
 
|category2=
 
|category2=
 
}}
 
}}
This tip presents an overview of how to download the source for Vim, then build a Vim executable, and install it on your system. You need to download the C source code and the runtime files (standard plugins, help files, and more). You may also need to download dependencies (packages required for building), and you will need a compiler/linker (free versions are available for almost all systems).
+
This tip presents an overview of how to download the source for Vim, then build a Vim executable, and install it on your system. You need to download the C source code and the runtime files (standard plugins, help files, and more). You may also need to download dependencies (packages required for building), and you will need a compiler/linker (free versions are available for almost all systems). See [[where to download Vim]] if you want to download the Vim program to run on your system, without building it yourself.
   
 
==Any platform==
 
==Any platform==
It is ''very'' easy to build Vim from the source code. We even have some [[:Category:Building_Vim|tips for building Vim]]. In general, it takes four steps:
+
It is easy to build Vim from the source code. In general, it takes four steps:
#Get dependencies. On Unix-like systems, <tt>apt-get build-dep vim-gnome</tt> or similar can do this for you. On Windows, there ''are'' no dependencies, unless you want to build Vim to use an external DLL for Lua, Perl, Python, Ruby, or Scheme (and you can install these later).
+
#Get dependencies. On Unix-like systems, <code>apt-get build-dep vim-gnome</code> or similar can do this for you. On Windows, there are no dependencies, unless you want to build Vim to use an external DLL for Lua, Perl, Python, Ruby, or Scheme (and you can install these later).
#:<div style="font-size:80%; line-height:1.1em">'''Note:''' <tt>apt-get</tt> is for Debian, Ubuntu and similar distributions. On other distributions, the corresponding program may be called <tt>yum, yast, zypper,</tt> or otherwise, and the way to invoke it may vary widely. It is usually the same program as the one used on your distro to install, update, or uninstall any software package, and if you are lucky, there may be a manpage for it.</div>
+
#:<div style="font-size:80%; line-height:1.1em">'''Note:''' <code>apt-get</code> is for Debian, Ubuntu and similar distributions. On other distributions, the corresponding program may be called <code>yum, yast, zypper,</code> or otherwise, and the way to invoke it may vary widely. It is usually the same program as the one used on your distro to install, update, or uninstall any software package, and if you are lucky, there may be a manpage for it.</div>
#[[Getting_the_Vim_source_with_Mercurial|Get the Vim source code from Mercurial]].
+
#[[Getting the Vim source with Mercurial|Get the Vim source code from Mercurial]] or a [https://github.com/b4winckler/vim GitHub clone].
 
#Change to the directory with the Vim source code and run "make".
 
#Change to the directory with the Vim source code and run "make".
#Do a "make install" or manually copy necessary files to somewhere Vim knows to use. See {{help|$VIMRUNTIME}} for details and our tip on [[Version_independent_installation_of_Vim_on_Windows|manually locating your Vim files]].
+
#Do a "make install" or manually copy necessary files to somewhere Vim knows to use. See {{help|$VIMRUNTIME}} for details and our tip on [[Version independent installation of Vim on Windows|manually locating your Vim files]].
   
 
==Building Vim on Ubuntu==
==Overview==
 
''The following applies to Unix-based systems, and Windows.''
 
 
Download the source from <tt>ftp://ftp.vim.org/pub/vim/unix/</tt>
 
*<tt>vim-7.2.tar.bz2</tt> (7.1MB)
 
 
Download the extras from <tt>ftp://ftp.vim.org/pub/vim/extra/</tt>
 
*<tt>vim-7.2-extra.tar.gz</tt> (0.8MB)
 
*<tt>vim-7.2-lang.tar.gz</tt> (1.4MB)
 
 
Expand each in the same directory, for example <tt>somewhere/vim/build/72/</tt>
 
 
Download the patches from <tt>ftp://ftp.vim.org/pub/vim/patches/7.2/</tt>
 
 
Apply the patches.
 
 
Configure.
 
 
Build (compile and link).
 
 
Install.
 
 
==Building GUI Vim on Ubuntu==
 
 
You need the required development packages on Ubuntu to build the GUI:
 
You need the required development packages on Ubuntu to build the GUI:
 
<pre>
 
<pre>
Line 49: Line 27:
 
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
 
libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
 
libcairo2-dev libx11-dev libxpm-dev libxt-dev
 
libcairo2-dev libx11-dev libxpm-dev libxt-dev
  +
</pre>
  +
  +
For ruby support, you need for package ruby-dev:
  +
<pre>
  +
sudo apt-get install ruby-dev
 
</pre>
 
</pre>
   
Line 60: Line 43:
 
$ sudo make install
 
$ sudo make install
 
</pre>
 
</pre>
  +
  +
===Building Vim .debs on Ubuntu/Debian===
  +
Commands to get started and build the first time.
  +
<pre>
  +
$ sudo apt-get install mercurial libssl-dev
  +
$ sudo apt-get build-dep vim
  +
$ hg clone http://hg.debian.org/hg/pkg-vim/vim
  +
$ cd vim
  +
$ hg checkout unstable
  +
$ debian/rules update-orig
  +
$ dpkg-buildpackage -i -I
  +
$ cd ..
  +
</pre>
  +
  +
And to update Vim .debs
  +
<pre>
  +
$ cd vim
  +
$ hg pull
  +
$ hg update
  +
$ debian/rules update-orig
  +
$ dpkg-buildpackage -i -I
  +
$ cd ..
  +
</pre>
  +
  +
==Building Vim on Windows==
  +
There are a couple options for a compiler on Windows. Vim ships with makefiles for Cygwin, MinGW, and Visual Studio. Visual Studio express is free to download and use from Microsoft and should work with the supplied makefile.
  +
  +
In general, you will invoke a make program and pass in the desired build options, like:
  +
<pre>
  +
make FEATURES=HUGE GUI=yes gvim.exe
  +
</pre>
  +
  +
Some more details and examples here:
 
*[[Build Vim in Windows with Cygwin]]
 
*[[Build Vim in Windows with Visual Studio]]
  +
*[[Build Python-enabled Vim on Windows with MinGW]]
  +
  +
After you've built Vim, run the compiled executable and do <code>:version</code> to verify it built as you intended. Then you're ready to install; close the Vim instance before you continue.
  +
  +
One option is to just install manually every time without any nice installer options like having .bat files in your system path to launch Vim from the command line, a default _vimrc, shell context-menu "Edit with Vim" item, etc.:
 
*[[Version independent installation of Vim on Windows]]
  +
  +
But most of the time you want to install Vim somewhere everybody on the computer can use it, and integrate it as if you installed from Bram's binary.
  +
  +
To do this, see the details in the INSTALLpc.txt file in the src directory of the code you downloaded. Basically it all boils down to:
  +
#Create a directory like <code>C:\Program Files\vim\vim74</code> or <code>C:\Vim\vim74</code>
  +
#Copy all .exe files from src (which you compiled) to that <code>vim74</code> directory.
  +
#Copy xxd.exe from src/xxd into <code>vim74</code>
  +
#Copy the .dll file from src/GvimExt into <code>vim74</code>
  +
#Copy all files and folders from the runtime directory in your downloaded source into that <code>vim74</code> directory
  +
#Run a cmd.exe prompt ''as administrator'' (i.e. right-click and choose "run as administrator" to give yourself admin rights in UAC).
  +
#Go to the <code>vim74</code> directory and run the install.exe file you copied over in step (2).
  +
  +
This will put Vim into a spot everybody can use it, and give you options to create default _vimrc, user config areas, .bat files for command-line use, "edit with Vim" context menu, etc.
   
 
==Miscellaneous==
 
==Miscellaneous==
In Vim, the command <tt>:version</tt> includes "Compiled by ''user''@''host''" (the user and computer host names are provided by the operating system).
+
In Vim, the command <code>:version</code> includes "Compiled by ''user''@''host''" (the user and computer host names are provided by the operating system).
   
The configuration option <tt>--with-compiledby</tt> can be used to set the exact "Compiled by" text (for example, to include an email address).
+
The configuration option <code>--with-compiledby</code> can be used to set the exact "Compiled by" text (for example, to include an email address).
   
==Comments==
+
==Using patches==
  +
:''Following works but is obsolete; see above for information on using Mercurial.''
See also:
 
 
:''The following applies to Unix-based systems, and Windows.''
* [[Build Vim in Windows with Cygwin]]
 
* [[Getting the Vim source with Mercurial]]
 
* the following HowTo pages about building Vim from source:
 
** [http://users.skynet.be/antoine.mechelynck/vim/compile.htm on Windows]
 
** [http://users.skynet.be/antoine.mechelynck/vim/compunix.htm on Unix/Linux]
 
--[[User:Tonymec|Tonymec]] 11:51, June 18, 2010 (UTC)
 
----
 
The [[Main Page]] links to [[Vim documentation]] and I would eventually like that page cleaned up with a new section about downloading and building Vim (no details, just links to relevant tips).
 
   
 
Download the source from <code>ftp://ftp.vim.org/pub/vim/unix/</code>
The following seem relevant (may need to merge):
 
 
*<code>vim-7.2.tar.bz2</code> (7.1MB)
*[[VimTip222|222 Building vim with color on HP-UX]]
 
*[[VimTip376|376 Build Vim with your name included]] want to develop this as our "how to build" tip
 
*[[VimTip531|531 Build Vim in Windows with Cygwin]]
 
*[[VimTip714|714 Version independent installation of Vim on Windows]]
 
*[[VimTip744|744 Get latest releases for syntax highlighting, runtime, plugins etc]]
 
*[[VimTip747|747 Easily keep runtime files up to date]]
 
*[[VimTip1311|1311 Compile a separate copy of Vim for Python coding]]
 
[[User:JohnBeckett|JohnBeckett]] 04:34, May 22, 2008
 
----
 
I think you're saying the same thing, but I certainly recommend leaving the "building" tips separate from this one. I've tried to add info at the top of this tip to indicate how easy it is, but I know most people just want a "grab and go" download they can use. Maybe we should move that section? It probably needs a little work, still. --[[User:Fritzophrenic|Fritzophrenic]] 20:23, July 10, 2010 (UTC)
 
:''Last two comments were at [[Where to download Vim]]. I have moved the comments with Fritzophrenic's new section to this page.'' [[User:JohnBeckett|JohnBeckett]] 08:43, July 12, 2010 (UTC)
 
   
 
Download the extras from <code>ftp://ftp.vim.org/pub/vim/extra/</code>
----
 
 
*<code>vim-7.2-extra.tar.gz</code> (0.8MB)
Need info on how to install the shell extensions (e.g. "edit with Vim" context menu entry) on Windows. Do we have a tip for this already?
 
 
*<code>vim-7.2-lang.tar.gz</code> (1.4MB)
Also for other stuff included in the standard installation, like 'diff.exe'.
 
   
 
Expand each in the same directory, for example <code>somewhere/vim/build/72/</code>
--[[User:Fritzophrenic|Fritzophrenic]] 20:30, August 18, 2010 (UTC)
 
:When you build Vim on Windows, you also get install.exe (built from src/dosinst.c), and I believe you are supposed to run that if you want "Edit with Vim" and file associations. I have never used it. Of course you can manually add "Edit with Vim" with manual registry changes (I don't use these either). There is info at {{help|gui_w32.txt}}. The relevant tips are:
 
:*[[VimTip636|636 Adding Vim to MS-Windows File Explorer Menu]]
 
:*[[VimTip861|861 Right click in Windows Explorer to open gvim in explorer mode]]
 
:*[[VimTip1003|1003 Windows file associations]]
 
:*[[VimTip1225|1225 Open files in multiple tabs using the Windows Context Menu]]
 
:*[[VimTip1314|1314 Add open-in-tabs context menu for Windows]]
 
:*[[VimTip1542|1542 Vim On Vista]] (the introductory para)
 
:The only tip with info on diff.exe is:
 
:*[[VimTip416|416 Running diff]]
 
:[[User:JohnBeckett|JohnBeckett]] 07:46, August 19, 2010 (UTC)
 
::I assumed this was what the install.exe thing was for, but when I finally uninstalled Vim 7.2 at home (since 7.3 is out of Beta), and ran install.exe, I just got errors about not running it from my vim73 directory (which doesn't exist at all). I suppose I'll post on vim_use about it, and hopefully put that info on the wiki when I figure out how to do it. --[[User:Fritzophrenic|Fritzophrenic]] 14:35, August 19, 2010 (UTC)
 
----
 
   
 
Download the patches from <code>ftp://ftp.vim.org/pub/vim/patches/7.2/</code>
Make sure the library names are correct for all or most distributions. In the Linux dist I'm using it seems the libraries are named <X>-devel instead of <X>-dev.
 
  +
--[[User:mikedgreene|mikedgreene]] 15:50 Feb 27, 2011 (UTC)
 
 
Apply the patches.
  +
 
Configure.
  +
 
Build (compile and link).
  +
 
Install.
  +
 
==See also==
  +
''Tips, some of which need updating''
 
*[[Building vim with color on HP-UX]]
 
*[[Compile a separate copy of Vim for Python coding]]
 
*[[Getting the Vim source with Mercurial]]
 
*[[Get latest releases for syntax highlighting, runtime, plugins etc]]
  +
*[[:Category:Building Vim|Category of tips for building Vim]]
  +
''External sites with how-to information on building Vim''
 
*[http://users.skynet.be/antoine.mechelynck/vim/compile.htm on Windows]
 
*[http://users.skynet.be/antoine.mechelynck/vim/compunix.htm on Unix/Linux]
  +
  +
==Comments==
  +
{{todo}}
 
*Where to get other stuff included in the standard installation, like <code>diff.exe</code>.
  +
  +
Merge or link to some of these?
 
*[[VimTip636|636 Adding Vim to MS-Windows File Explorer Menu]]
 
*[[VimTip861|861 Right click in Windows Explorer to open gvim in explorer mode]]
 
*[[VimTip1003|1003 Windows file associations]]
 
*[[VimTip1225|1225 Open files in multiple tabs using the Windows Context Menu]]
 
*[[VimTip1314|1314 Add open-in-tabs context menu for Windows]]
 
*[[VimTip1542|1542 Vim On Vista]] (the introductory para)
 
The only tip with info on diff.exe is:
 
*[[VimTip416|416 Running diff]]
  +
 
----
 
Make sure the library names are correct for all or most distributions. In the Linux dist I'm using it seems the libraries are named <X>-devel instead of <X>-dev. [[User:Michael Greene|Michael Greene]] 15:50 Feb 27, 2011 (UTC)

Revision as of 22:35, 29 March 2014

Tip 376 Printable Monobook Previous Next

created 2002 · complexity basic · version 7.0


This tip presents an overview of how to download the source for Vim, then build a Vim executable, and install it on your system. You need to download the C source code and the runtime files (standard plugins, help files, and more). You may also need to download dependencies (packages required for building), and you will need a compiler/linker (free versions are available for almost all systems). See where to download Vim if you want to download the Vim program to run on your system, without building it yourself.

Any platform

It is easy to build Vim from the source code. In general, it takes four steps:

  1. Get dependencies. On Unix-like systems, apt-get build-dep vim-gnome or similar can do this for you. On Windows, there are no dependencies, unless you want to build Vim to use an external DLL for Lua, Perl, Python, Ruby, or Scheme (and you can install these later).
    Note: apt-get is for Debian, Ubuntu and similar distributions. On other distributions, the corresponding program may be called yum, yast, zypper, or otherwise, and the way to invoke it may vary widely. It is usually the same program as the one used on your distro to install, update, or uninstall any software package, and if you are lucky, there may be a manpage for it.
  2. Get the Vim source code from Mercurial or a GitHub clone.
  3. Change to the directory with the Vim source code and run "make".
  4. Do a "make install" or manually copy necessary files to somewhere Vim knows to use. See :help $VIMRUNTIME for details and our tip on manually locating your Vim files.

Building Vim on Ubuntu

You need the required development packages on Ubuntu to build the GUI:

sudo apt-get install libncurses5-dev libgnome2-dev libgnomeui-dev \
  libgtk2.0-dev libatk1.0-dev libbonoboui2-dev \
  libcairo2-dev libx11-dev libxpm-dev libxt-dev

For ruby support, you need for package ruby-dev:

sudo apt-get install ruby-dev

Commands to build and install GUI Vim:

$ cd vim7
$ cd src
$ make distclean
$ ./configure --with-features=huge --enable-gui=gnome2
$ make
$ sudo make install

Building Vim .debs on Ubuntu/Debian

Commands to get started and build the first time.

$ sudo apt-get install mercurial libssl-dev
$ sudo apt-get build-dep vim
$ hg clone http://hg.debian.org/hg/pkg-vim/vim
$ cd vim
$ hg checkout unstable
$ debian/rules update-orig
$ dpkg-buildpackage -i -I
$ cd ..

And to update Vim .debs

$ cd vim
$ hg pull
$ hg update
$ debian/rules update-orig
$ dpkg-buildpackage -i -I
$ cd ..

Building Vim on Windows

There are a couple options for a compiler on Windows. Vim ships with makefiles for Cygwin, MinGW, and Visual Studio. Visual Studio express is free to download and use from Microsoft and should work with the supplied makefile.

In general, you will invoke a make program and pass in the desired build options, like:

make FEATURES=HUGE GUI=yes gvim.exe

Some more details and examples here:

After you've built Vim, run the compiled executable and do :version to verify it built as you intended. Then you're ready to install; close the Vim instance before you continue.

One option is to just install manually every time without any nice installer options like having .bat files in your system path to launch Vim from the command line, a default _vimrc, shell context-menu "Edit with Vim" item, etc.:

But most of the time you want to install Vim somewhere everybody on the computer can use it, and integrate it as if you installed from Bram's binary.

To do this, see the details in the INSTALLpc.txt file in the src directory of the code you downloaded. Basically it all boils down to:

  1. Create a directory like C:\Program Files\vim\vim74 or C:\Vim\vim74
  2. Copy all .exe files from src (which you compiled) to that vim74 directory.
  3. Copy xxd.exe from src/xxd into vim74
  4. Copy the .dll file from src/GvimExt into vim74
  5. Copy all files and folders from the runtime directory in your downloaded source into that vim74 directory
  6. Run a cmd.exe prompt as administrator (i.e. right-click and choose "run as administrator" to give yourself admin rights in UAC).
  7. Go to the vim74 directory and run the install.exe file you copied over in step (2).

This will put Vim into a spot everybody can use it, and give you options to create default _vimrc, user config areas, .bat files for command-line use, "edit with Vim" context menu, etc.

Miscellaneous

In Vim, the command :version includes "Compiled by user@host" (the user and computer host names are provided by the operating system).

The configuration option --with-compiledby can be used to set the exact "Compiled by" text (for example, to include an email address).

Using patches

Following works but is obsolete; see above for information on using Mercurial.
The following applies to Unix-based systems, and Windows.

Download the source from ftp://ftp.vim.org/pub/vim/unix/

  • vim-7.2.tar.bz2 (7.1MB)

Download the extras from ftp://ftp.vim.org/pub/vim/extra/

  • vim-7.2-extra.tar.gz (0.8MB)
  • vim-7.2-lang.tar.gz (1.4MB)

Expand each in the same directory, for example somewhere/vim/build/72/

Download the patches from ftp://ftp.vim.org/pub/vim/patches/7.2/

Apply the patches.

Configure.

Build (compile and link).

Install.

See also

Tips, some of which need updating

External sites with how-to information on building Vim

Comments

 TO DO 

  • Where to get other stuff included in the standard installation, like diff.exe.

Merge or link to some of these?

The only tip with info on diff.exe is:


Make sure the library names are correct for all or most distributions. In the Linux dist I'm using it seems the libraries are named <X>-devel instead of <X>-dev. Michael Greene 15:50 Feb 27, 2011 (UTC)