install vim in ubuntu

As the name implies, Vi Improved (Vim) is an implementation of the classic vi editor that includes various extra features from window splitting and macros to an extensive plugin system.

Ubuntu ships with vim-tiny which only provides the vi command. This means you can use Vim by default, but it’ll only be a barebones version. If you want access to all the features of Vim, you’ll have to manually install an appropriate vim version.

Install Vim from Ubuntu Repo

There are a number of Vim variants available in the Ubuntu repo (vim, vim-athena, vim-gtk3, vim-nox, vim-tiny, etc). The main difference between these is that they’re compiled with different GUIs, have different dependencies, and are intended for slightly different environments.

For instance, vim-tiny is a minimal build with only 12 basic features enabled out of 120. vim-nox includes more features but doesn’t have a GUI. vim-gtk3 is compiled with a GNOME GUI, while vim-athena is compiled with the Athena GUI.

In our case, we’ll install the vim package as it’s compiled with a standard set of features. Keep in mind that this version doesn’t provide a GUI or scripting language support though. So, if you need those features, install another appropriate vim variant; the process is the same.

sudo apt install vim

You can verify the installation by checking the vim version.

vim --version

Similarly, you can launch vim in command mode, or open a specific file to edit like so

vim
vim /path/to/file

Build Vim from Source

It’s also possible to build Vim yourself with the set of features that you want. You should first check the list of features from the Vim documentation on SourceForge. In the feature-list section, the features are prefixed by certain letters.

TTinyMinimal features only
SSmallBasic set of features
NNormalStandard set of features
BBigMost features enabled
HHugeAll features enabled
mManualManually enabled features

Install Required Dependencies

Most required dependencies for a standard install will be already installed on your system. In case they aren’t, the following command should cover most of them.

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

Obtain Source and Compile Vim

Clone the git repo and navigate to the src directory.

git clone https://github.com/vim/vim.git
cd vim
cd src

Now, configure your Vim build. You can check the full list of configuration options with ./configure --help. In our case, we’ll use the Huge set of features from earlier to enable all features.

./configure --with-features=huge

Finally, use make to compile Vim.

make
sudo make install

After compiling it, you can launch vim with

vim

This’ll launch the binary from /usr/local/bin/vim. If you have another vim version installed using apt, you can launch by entering the full path (/usr/bin/vim).

Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.