Dec 23, 2020 • 3 min read
Compiling Vim
“Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as “vi” with most UNIX systems and with Apple OS X.”
This tutorial covers the steps required to compile Vim from source with Python support (i.e. python3.x). If you use ChromeOS or a Linux distribution, it may not necessarily have access to the latest build of the application. To get past this issue, compiling from source provides the best approach. Learn how to build Vim, so understand how to enable example packages needed for plugins based on Python.
Vim Configuration
This is a really quick guide to configuring Vim
- Check the Vim version
- Remove unnecessary packages
- Install the require packages
- Get the Vim source code
- Build the source code
- Test the generated package
Which version of Vim
In this blog post I am using Vim. In most instances you should not have to update the version of Vim on your host. If you use certain plugins e.g. YouCompleteMe, they will complain if you do not have a current version of Vim.
Build from Source
Building from source is well documented.
-
Check the Vim version
NODE_TYPE // textvim --version -
Install Packages
Get rid of the existing Vim
NODE_TYPE // textsudo apt autoremove vim vim-runtime gvimGet rid of the deprecated python 2.x
NODE_TYPE // textsudo apt autoremove python2*Add build packages
- git
- libatk1.0-dev
- libcairo2-dev
- libgtk2.0-dev
- liblua5.1-0-dev
- libncurses5-dev
- libperl-dev
- libx11-dev
- libxpm-dev
- libxt-dev
- lua5.1
- python3-dev
NOTE: Expand the code below if you get an error!
NODE_TYPE // textsudo apt install -y git \ libatk1.0-dev \ libcairo2-dev \ libgtk2.0-dev \ liblua5.1-0-dev \ libncurses5-dev \ libperl-dev \ libx11-dev \ libxpm-dev \ libxt-dev \ lua5.1 \ python3-dev \ ruby-dev -
Move to the home folder
NODE_TYPE // textcd ~Ref: VIM
-
Get VIM from github
NODE_TYPE // textgit clone https://github.com/vim/vim.git -
Enter the archive directory
NODE_TYPE // textcd ~/vim -
Set the Python configuration e.g.
NODE_TYPE // textPYTHON_VER=$("echo $(python3-config --configdir) | awk -F '/' '{print$4}'")NOTE: Python Dev comes with a utility to indicate the correct path e.g.
NODE_TYPE // bashpython3-config --configdirWill output the Python path
NODE_TYPE // output/usr/lib/python3.11/config-3.11-x86_64-linux-gnu -
Add configuration
NODE_TYPE // text./configure --with-features=huge \ --enable-multibyte \ --enable-rubyinterp=yes \ --enable-python3interp=yes \ --with-python3-command=$PYTHON_VER \ --with-python3-config-dir=$(python3-config --configdir) \ --enable-perlinterp=yes \ --enable-gui=gtk2 \ --enable-cscope \ --prefix=/usr/local -
Compile the source and install
NODE_TYPE // textmake && sudo make install -
Confirm the Vim configuration and grep on Python3 support (i.e. +Python3)
NODE_TYPE // textvim --version | grep +python3 -
Add the vim command as an Alias to
~/.bashrc
alias vi="/usr/local/bin/vim"Congrats! You have a custom build of Vim.