1. Overview

vi is a powerful and widely used text editor in the Linux ecosystem. It’s a command-line editor that helps in editing configuration files, scripts, and text files. Since it’s such an integral part of the Linux environment, it’s sometimes important to know the version of vi present on the system.

The version of vi installed can affect its functionality, compatibility with other software, and overall performance. It’s also important to know the version when troubleshooting issues or when looking for upgrades or updates.

In this tutorial, we’ll discuss different methods to check the version of the vi editor on a Linux machine.

2. Using the vi Command

We can check the version of vi installed on a machine using the –version option of the vi command:

$ vi --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 15 2020 16:43:23)

The output displays the current version of the vi editor, i.e., 7.4. Additionally, it includes other information such as the compiler used to build the binary and other optional features.

It’s worth noting that this method may not work on all systems. It depends on the specific version of vi installed and how it was installed.

Another way to find the version is from within vi itself. Let’s open a terminal and type the command vi and press enter:

Vi Editor Homepage

Once the editor is open, we press the Esc key and type :version and press enter:

Vi Editor additional info

This displays the current version of vi on the system, along with other information such as the compile date and the specific release version.

3. Using Package Managers

We can find the version of vi editor installed on a Linux machine using the package manager, such as dpkg, rpm, yum etc.

The package manager keeps track of all the software packages installed on the system, including their versions.

On Debian-based distributions such as Ubuntu, we can use the dpkg command to list all the packages installed on the system and check the version of vi:

$  dpkg -l | grep vim
ii  vim                        2:8.2.2434-3+deb11u1           amd64        Vi IMproved - enhanced vi editor
ii  vim-common                 2:8.2.2434-3+deb11u1           all          Vi IMproved - Common files
ii  vim-runtime                2:8.2.2434-3+deb11u1           all          Vi IMproved - Runtime files

For Red Hat-based distributions such as CentOS, we can use the rpm command to list all the packages installed on the system and check the version of vi:

$ rpm -qa | grep vim
vim-minimal-7.4.629-8.el7_9.x86_64

On Fedora we can use the dnf command:

$ dnf list installed | grep -i "vim-minimal"
vim-minimal.x86_64                       2:8.2.5046-1.fc34                 @updates

These commands list all the packages installed on the system and grep filters out only the vim package. The output displays the version of vi.

4. Conclusion

In this article, we discussed different methods to check the version of vi installed on a Linux machine. First, we looked at a common way through the vi –version command. After that, we explored the same using the package manager utilities dpkg, rpm and dnf.