Building Vim from source(转)
Compiling Vim from source is actually not that difficult. Here's what you should do:
-
First, install all the prerequisite libraries, including Git. For a Debian-like Linux distribution like Ubuntu, that would be the following:
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 python-dev \ python3-dev ruby-dev lua5.1 lua5.1-dev libperl-dev git
On Ubuntu 16.04,
liblua5.1-dev
is the lua dev package name notlua5.1-dev
.(If you know what languages you'll be using, feel free to leave out packages you won't need, e.g. Python2
python-dev
or Rubyruby-dev
. This principle heavily applies to the whole page.)For Fedora 20, that would be the following:
sudo yum install -y ruby ruby-devel lua lua-devel luajit \ luajit-devel ctags git python python-devel \ python3 python3-devel tcl-devel \ perl perl-devel perl-ExtUtils-ParseXS \ perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \ perl-ExtUtils-Embed
This step is needed to rectify an issue with how Fedora 20 installs XSubPP:
# symlink xsubpp (perl) from /usr/bin to the perl dir sudo ln -s /usr/bin/xsubpp /usr/share/perl5/ExtUtils/xsubpp
-
Remove vim if you have it already.
sudo apt-get remove vim vim-runtime gvim
On Ubuntu 12.04.2 you probably have to remove these packages as well:
sudo apt-get remove vim-tiny vim-common vim-gui-common vim-nox
-
Once everything is installed, getting the source is easy.
Note: If you are using Python, your config directory might have a machine-specific name (e.g.
config-3.5m-x86_64-linux-gnu
). Check in /usr/lib/python[2/3/3.5] to find yours, and change thepython-config-dir
and/orpython3-config-dir
arguments accordingly.Note for Ubuntu 14.04 (Trusty) users: You can only use Python 2 or Python 3. If you try to compile vim with both
python-config-dir
andpython3-config-dir
, it will give you an errorYouCompleteMe unavailable: requires Vim compiled with Python (2.6+ or 3.3+) support
.Add/remove the flags below to fit your setup. For example, you can leave out
enable-luainterp
if you don't plan on writing any Lua.Also, if you're not using vim 8.0, make sure to set the VIMRUNTIMEDIR variable correctly below (for instance, with vim 8.0a, use /usr/share/vim/vim80a). Keep in mind that some vim installations are located directly inside /usr/share/vim; adjust to fit your system:
cd ~ git clone https://github.com/vim/vim.git cd vim ./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp=yes \ --enable-pythoninterp=yes \ --with-python-config-dir=/usr/lib/python2.7/config \ --enable-python3interp=yes \ --with-python3-config-dir=/usr/lib/python3.5/config \ --enable-perlinterp=yes \ --enable-luainterp=yes \ --enable-gui=gtk2 \ --enable-cscope \ --prefix=/usr/local make VIMRUNTIMEDIR=/usr/local/share/vim/vim80
On Ubuntu 16.04, Python support was not working due to enabling both Python2 and Python3. Read answer by chirinosky for workaround.
In practice, Python2 and Python3 are not working at the same time on Ubuntu 14.04.5 LTS. Choosing one of them is OK.
If you want to be able to easily uninstall vim use
checkinstall
.sudo apt-get install checkinstall cd ~/vim sudo checkinstall
Otherwise, you can use
make
to install.cd ~/vim sudo make install
Set vim as your default editor with
update-alternatives
.sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 1 sudo update-alternatives --set editor /usr/bin/vim sudo update-alternatives --install /usr/bin/vi vi /usr/bin/vim 1 sudo update-alternatives --set vi /usr/bin/vim
-
Double check that you are in fact running the new Vim binary by looking at the output of
vim --version
.If you don't get gvim working (on ubuntu 12.04.1 LTS), try changing
--enable-gui=gtk2
to--enable-gui=gnome2
If you have problems, double check that you
configure
d using the correct Python config directory, as noted at the beginning of Step 3.These
configure
andmake
calls assume a Debian-like distro where Vim's runtime files directory is placed in/usr/share/vim/vim80/
, which is not Vim's default. Same thing goes for--prefix=/usr
in theconfigure
call. Those values may need to be different with a Linux distro that is not based on Debian. In such a case, try to remove the--prefix
variable in theconfigure
call and theVIMRUNTIMEDIR
in themake
call (in other words, go with the defaults).If you get stuck, here's some other useful information on building Vim.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2015-08-31 整数中1出现的次数(从1到n整数中1出现的次数)
2015-08-31 连续子数组的最大和
2015-08-31 最小的K个数
2015-08-31 数组中出现次数超过一半的数字
2015-08-31 字符串的排列