Building Vim from Source
Most Linux distributions ship a stripped-down Vim — often without +python3, +clipboard, or GUI support, and rarely the newest release. Building Vim yourself fixes all of that: you decide exactly which language interpreters and features get compiled in, and you get whatever version is on Vim’s master branch.
The process is straightforward. This guide walks through it on a Debian-based distro such as Ubuntu.
Note: This post has been updated from its original 2013 version to match how Vim is built today. The source has moved from vim.org’s Mercurial repository to GitHub, the Python 2 interpreter has been swapped for Python 3 and the GTK2 GUI for GTK3, and
configureflags that newer Vim removed (such as--enable-sniffand the now-default--enable-multibyte) have been dropped.
Install the prerequisites
sudo apt install git libncurses-dev libgtk-3-dev libatk1.0-dev \
libcairo2-dev libx11-dev libxpm-dev libxt-dev \
python3-dev ruby-dev libperl-dev liblua5.4-dev
Remove any existing Vim
sudo apt remove vim vim-runtime gvim vim-tiny vim-common vim-gui-common
Build from source
Get the source code
Vim’s source now lives on GitHub, so clone it directly:
git clone https://github.com/vim/vim.git
Configure
cd vim
./configure \
--with-features=huge \
--enable-rubyinterp \
--enable-python3interp \
--enable-luainterp \
--enable-perlinterp \
--enable-cscope \
--enable-fontset \
--enable-gui=gtk3 \
--prefix=/usr
Note:
--prefix=/usrabove, together withVIMRUNTIMEDIRin the next step, assumes a Debian-like layout where Vim’s runtime files go in/usr/share/vim/vim91/. Thevim91part tracks the version you cloned (Vim 9.1 →vim91). On a non-Debian distro the paths may differ — in that case drop both--prefixhere andVIMRUNTIMEDIRbelow and let the defaults take over.
Compile and install
make VIMRUNTIMEDIR=/usr/share/vim/vim91
sudo make install
Confirm the features you asked for made it in:
vim --version
Troubleshooting
gvimwon’t start. Rebuild with a different GUI toolkit, e.g. swap--enable-gui=gtk3for--enable-gui=gtk2.Backspace doesn’t work. Add these lines to your
.vimrc:set nocompatible set backspace=indent,eol,start
The Disqus comment system is loading ...
If the message does not appear, please check your Disqus configuration.