How to Install Vim on Ubuntu

install vim ubuntu

Vim (Vi IMproved) is one of the best Linux text editors with extensive customization features. It is a must-have for any Ubuntu user who is a terminal enthusiast, system administrator, or software developer. With command knowledge, no other text editor allows for extensive editing like Vim.

This guide is meant to help you install Vim on Ubuntu, from the simplest to the more involved methods.

Understanding Vim and Its Variants

Vim is an upgraded version of the vi editor, which comes standard with every Unix system. It features:

  • Modal editing (two or more modes of inserting text and executing commands)
  • Highly customizable through .vimrc settings profile
  • Advanced search and replace features
  • Syntax highlighting for many hundreds of programming languages
  • A plug-in system for extending functionality
  • Support for many development tools

Acquiring Vim requires a bit of research regarding its different versions. For Ubuntu, the following apply:

  1. vim-tiny: a minimal version with basic features enabled (frequently comes pre-installed with Ubuntu)
  2. vim: Standard version with the typical features enabled
  3. vim-gtk3: GUI version supporting GTK3(gVim)
  4. vim-nox: an upgraded version that permits the use of some scripts (Perl, Python, Ruby, etc.)
  5. vim-athena: GUI version that uses the Athena widget set
  6. neovim: New implementation of Vim with modern extensions

Depending on whether you prefer a GUI or require additional languages, select the variant that matches your work style. 

Ubuntu has a default package manager, the Advanced Package Tool (APT). This section helps you get started with Vim on Ubuntu using the APT package by describing multiple installation methods. To install the standard version of Vim, follow the below steps:

Before proceeding with the Vim installation, first, check the Ubuntu version to avoid compatibility issues.

Step 1: Update Package Index

Make sure you update the package list because it will add any more recent changes made to the repositories. Doing so makes sure that all installed packages, as well as the operating system, are up to date. It helps to avoid problems while installing new packages:

sudo apt update
update packages list

Step 2: Install Vim in Ubuntu

This is the simplest method to install Vim on Ubuntu. These are the available packages for Vim:

1. Minimal Package (vim-tiny) 

For Basic functionality, install the Vim tiny editor:

sudo apt install vim-tiny
install vim tiny

2. Vim Install Ubuntu (Standard Version) 

This is more suited for the average user. To install the standard version of Vim, use the below command. It installs the regular version of Vim with standard features.

sudo apt install vim
install vim standard version

3. Install Vim Full Version (vim-gtk3 or vim-gnome)

For the GUI version with GTK3 support, install the below package. It includes a GUI and additional features:

sudo apt install vim-gtk3
install vim full version

4. All Variants – Installs All Available Vim Packages

For those who want all available packages for Vim installed in one go:

sudo apt install vim-*
install vim with all packages

Step 3: Verify Installation

As Vim is now installed, let’s check whether it has been installed correctly. For this purpose, you can check the version installed:

vim --version
verify vim installation on ubuntu

This command shows the version and details of a compilation of Vim installed.

Method 2: Install Vim Using Snap

Snap is a type of universal package manager used in many distributions of Linux. Installing Snap ensures you get the same experience when using Vim.

Step 1: Check Whether Snap is Installed

Most modern versions of Ubuntu come with Snap pre-installed. Check that with:

snap --version
verify snap installation

If not installed, you can install Snap on Ubuntu with:

sudo apt install snapd
install snapd on ubuntu

Step 2: Using Snap To Install Vim

Remember that when installing Snap, you might have to use the command vim-editor instead of vim to access it:

sudo snap install --edge vim-editor 
install vim ubuntu snap

Step 3: Confirm Installation

After installation, check the installed version:

vim-editor --version
confirm vim installation

Method 3: Install Vim Using the Ubuntu Software Center

For those who prefer a graphical interface, this method is fit for you. Let’s follow the instructions below:

Open “Ubuntu Software” from the application window. Then in the search bar, look for “vim”; if not installed, get the most up-to-date version (vim, vim-gtk3, etc.):

locate vim ubuntu app center

Click “Install” and enter your password when prompted. After confirmation, your machine will wait to complete the installation:

install vim gui

Method 4: Install Vim from the Source

If you desire the most updated features of Vim or have specific alteration needs you want fulfilled. Getting a custom version of the software is often most easily done by compiling from source.

Step 1: Install Dependencies

Use the following command to set up the required dependencies:

sudo apt update & sudo apt install build-essential libncurses5-dev libncursesw5-dev git
install dependencies

Step 2: Download Vim Source Code

After that, download and get the available repository using the git command:

git clone https://github.com/vim/vim.git
download vim source code

Step 3: Configure and Compile

In addition to adding support for Ruby, Python 3, Perl, Lua, and GTK3 GUI, the configuration also adds support for them. For this, execute the below command to navigate to the vim directory:

cd vim

After this, execute the following code:

./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-python3interp=yes \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk3 \
            --enable-cscope \
            --prefix=/usr/local
configure vim

Keep in mind that, depending on the speed of your system, compiling the source can take quite a bit of time:

make
compile vim

Finally, install Vim using the below command:

sudo make install
install vim source code

Step 4: Verify Installation

Let’s confirm the installation of Vim:

/usr/local/bin/vim --version
verify vim installation

Once everything is aligned as it should be, now is a good time to use the device for the first time and test whether all operations are seamless. Let’s launch Vim:

vim
open vim

You can exit Vim by typing :q and pressing Enter.

Uninstall Vim on Ubuntu

If you need to remove Vim from the Ubuntu operating system, follow the below instructions:

For APT Installations

If the software was added via APT, use:

sudo apt autoremove vim vim-*
uninstall vim apt

For Snap installations:

To erase the software that’s installed using snap, try using this command in the console:

sudo snap remove vim-editor
remove vim snap

For GUI installations:

If you installed Vim using the Ubuntu Software Center (GUI), you can remove it just as easily through the same interface:

remove vim gui

For Source installations:

If the software was added via source file, navigate to the vim directory using cd ~/vim and run:

sudo make uninstall
uninstall vim source

That is all from the guide. You now have the tools to install and configure Vim according to your needs, from APT installation to compiling from source.

Conclusion

For Linux operating systems, Vim is certainly one of the most efficient and popular text editors available. The text editor VIM is highly efficient and, when used properly, can greatly increase productivity. There are several ways to install it on Ubuntu; the APT way is the easiest for most users, while the source installation is best for those who require specific features or need the latest version.

Experience Ultahost’s cheap Linux VPS hosting for better performance and reliability at a budget-friendly cost. Ultahost offers complete flexibility and control while handling all server management, ensuring everything runs smoothly and reliably with guaranteed uptime!

FAQ

What’s the difference between Vim and Vi?
How do I exit Vim?
What Vim package for programming should I install?
Does Vim provide syntax highlighting for my programming language?
How do I copy and paste between Vim and other applications?
What’s the advantage of installing Vim from the source?
Is Neovim better than Vim? Should I use it instead?

Related Post

How to Install Minikube on Ubuntu

Minikube is a lightweight, portable, and easy-to-use wa...

How to Install Java on Ubuntu 22.04

Java is a flexible programming language that can be use...

How to Install cPanel on Ubuntu

cPanel is a web-based control panel software that provi...

How to Connect to SQLite from the Command Lin

SQLite is a lightweight, self-contained, and serverless...

How to Install SQLite on Ubuntu 22.04

As a system administrator or developer, you are likely ...

How to Install ELK Stack on Ubuntu

The ELK Stack, comprising Elasticsearch, Logstash, and ...

Leave a Comment