How to Install Neovim on Ubuntu 24.04, 22.04, or 20.04

Neovim is a highly customizable, modernized fork of Vim, designed to improve the extensibility and user experience of the classic text editor. It introduces features like asynchronous plugins, a built-in terminal emulator, and Lua scripting capabilities, making it a powerful tool for developers and power users who need a versatile and efficient text editor. Neovim retains Vim’s powerful editing features while offering improvements that streamline development workflows.

On Ubuntu 24.04, 22.04, or 20.04, Neovim can be installed via several methods, depending on your needs for stability or cutting-edge features. The easiest method is through the Ubuntu default repository, which provides a stable version suitable for most users. For those who want the latest stable or even pre-release versions, the Neovim Team’s Launchpad PPA offers more up-to-date builds. Alternatively, Neovim can also be installed via Snap through Snapcraft or as a Flatpak via Flathub, providing sandboxed environments and easier updates. This guide will walk you through all these installation options, allowing you to choose the best method for your setup.

Update Ubuntu Before Neovim Installation

Before installing, updating your Ubuntu system to ensure optimal performance and compatibility is crucial. To update your system, execute the following command in the terminal:

sudo apt update && sudo apt upgrade

This command updates your package list and installs any available updates.

Method 1: Install Neovim via Ubuntu or PPA Option

Option 1: Install Neovim with Ubuntu Repository

For many users, the most straightforward and convenient method to install Neovim is through the standard repository. To install this version, run the following command:

sudo apt install neovim

Please note that this method installs the version of Neovim available in the official Ubuntu repository, which may not be the most recent version. For users seeking the latest updates and features, consider using one of the Neovim team’s PPA versions as an alternative installation method.

Option 2: Install Neovim with Neovim Team PPA

The second method for installation of Neovim is to import either the stable or unstable (nightly) version directly from the Neovim LaunchPAD PPA. Use one of the following commands based on the version you want to install:

Import Neovim stable PPA:

sudo add-apt-repository ppa:neovim-ppa/stable -y

Import Neovim unstable PPA:

sudo add-apt-repository ppa:neovim-ppa/unstable -y

Next, update your package index to include the newly added PPA:

sudo apt update

Now, you can proceed to install Neovim using the following command:

sudo apt install neovim

Once completed, the Neovim Team PPA will have installed Neovim on your system. Verify the installation of the PPA version by running the following command:

apt-cache policy neovim

Example output shows the Neovim PPA installed on Ubuntu, using the unstable version for this guide.

Method 2: Install Neovim via Snapd

The Snapcraft package manager can be your third option when installing Neovim on Ubuntu. Your Ubuntu desktop should already have Snap installed unless you removed it.

Although Snapcraft is not as popular as Flatpak, it comes from the same developers behind Ubuntu. Flatpak enjoys broader adoption across different Linux distributions, leading package maintainers to update Flatpak versions faster than Snapcraft versions. However, update speed ultimately relies on the specific package maintainer.

If you’ve uninstalled snapd from your system, use the following command to reinstall it:

sudo apt install snapd

Some packages require classic snap support. To enable this, create a symlink with the following command for optimal snap compatibility:

sudo ln -s /var/lib/snapd/snap /snap

Install the core files to prevent conflicts:

sudo snap install core

Finally, install the snap version of Neovim:

sudo snap install nvim --classic

After completing these steps, you have successfully installed Neovim on your system with the Snapcraft package manager.

Method 3: Install Neovim with Flatpak via Flathub

An alternative method for installing Neovim is Flatpak, a versatile package management system that provides a sandboxed application environment. To install Neovim via Flatpak, you must add the Flathub repository containing the Neovim package.

Note: If Flatpak isn’t installed on your system, please refer to How to Install Flatpak on Ubuntu with the Flatpak Team Official LaunchPAD PPA. This guide offers instructions for obtaining the latest supported version using the Flatpak Team Official LaunchPAD PPA.

Begin by opening the terminal and entering the following command to integrate the Flathub repository:

sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo

Now, run the Neovim installation using the following flatpak command:

flatpak install flathub io.neovim.nvim

Upon completing these steps, you installed Neovim on your system with the Flatpak and Flathub package manager.

Launch Neovim via CLI or GUI

There are several methods for launching Neovim, depending on your installation method and preference.

CLI Methods to Launch Neovim

Standard Installation: If you installed Neovim using the default repository, PPA, or built it from source, launch Neovim by entering the following command in your terminal:

neovim

Snapcraft: If you installed Neovim using Snapcraft, launch it from the terminal with the following command:

sudo snap run neovim

Flatpak: If you installed Neovim using Flatpak, run the following command in the terminal:

flatpak run io.neovim.nvim

GUI Method to Launch Neovim

Desktop Application: For desktop users, locate the Neovim application icon by navigating to Activities > Show Applications > Neovim. You can also add Neovim to your favorites for easy access.

Additional Commands For Neovim

Update Neovim

To ensure that you are using the latest version of Neovim, it’s crucial to check for updates regularly. While update notifications may appear automatically, verifying updates’ availability manually is good practice. Depending on your installation method, use one of the following commands in the terminal to check and apply updates for Neovim:

APT Neovim Update Method

To update Neovim installed via the APT method, first update the package list and then upgrade the packages:

sudo apt update && sudo apt upgrade

Flatpak Neovim Update Method

To update Neovim installed via Flatpak, execute the following command:

flatpak update

Snap Neovim Update Method

To update Neovim installed via Snap, run the following command:

sudo snap refresh

By regularly updating Neovim, you can benefit from the latest features, improvements, and bug fixes, ensuring a smooth and efficient experience.

Remove Neovim

If you no longer need Neovim on your system, follow the instructions below to uninstall it, depending on the original installation method. Additionally, these steps will help you clean up any leftover files and data to maintain a clutter-free system.

APT Neovim Remove Method

To uninstall Neovim installed via the APT method, execute the following command:

sudo apt remove neovim

If you installed Neovim using one of the PPAs, remove them with these commands:

Remove Neovim Stable PPA:

sudo add-apt-repository --remove ppa:neovim-ppa/stable -y

Remove Neovim Unstable PPA:

sudo add-apt-repository --remove ppa:neovim-ppa/unstable -y

Flatpak Neovim Remove Method

To uninstall Neovim installed via Flatpak, run the following command:

flatpak remove  --delete-data io.neovim.nvim -y

Snap Neovim Remove Method

To uninstall Neovim installed via Snapcraft, use the following command:

sudo snap remove neovim

Conclusion

With Neovim installed on your Ubuntu system using your preferred method, you can take full advantage of its enhanced features for efficient text editing and development. Whether you opt for the stability of the Ubuntu default repository, the latest updates from the Neovim Team PPA, or the flexibility of Snap or Flatpak, each installation method provides a reliable way to access Neovim’s capabilities. Regular updates, particularly through the PPA or Snap/Flatpak, will ensure that your Neovim setup remains current, enabling you to utilize its powerful editing tools effectively. Enjoy the flexibility and power that Neovim brings to your development environment on Ubuntu.

Leave a Comment