CentOS

How to fix the “vim: command not found” error in CentOS

Vim is known as a potent editor full of its features in a Linux terminal. Many Linux administrators prefer to edit the configuration files in an editor, which provides some other helpful features to get things done easily and early instead of just writing text in any text editor.

When a Linux user or administrator executes the vim command to use vim editor, he/she might face an error like “vim: command not found.” The only reason behind this error is that either the package is not installed or it is broken due to any reason.

In this post, you will have a step-by-step guide on fixing the error “vim: command not found” and how to install VIM text editor in CentoS or any RHEL-based Linux operating system.

Installation of VIM on CentOS 8

VIM is available in its default DNF package repository and installed from there in CentOS 8 Machine.

Before executing the VIM installation command, please update the repository cache of the system, and you can do so using the command:

$ sudo dnf makecache

Enable the EPEL repository if it is not enabled already using the command:

$ sudo dnf install epel-release

Upgrade the pre-installed packages as well to have fresh packages in the system:

$ sudo dnf upgrade

Once you performed all the tasks mentioned above, there will be no hurdle in installing and fixing the “vim: command not found” error on CentOS 8 Machine.

To install VIM on CentOS 8 Machine, execute the command:

$ sudo dnf install vim -y

The “-y” flag is for answering yes to any prompt that will occur during the installation process.

Within a few moments, the VIM text editor will be installed.

How to use VIM

After installation, type the vim command to open the VIM editor in the terminal and start using it:

$ vim

As you can have a fresh look at the welcome screen of the VIM editor in the screenshot attached above, it is verified that VIM is successfully installed, and you can use it for your needs.

Press “i” for getting into insertion mode and type something into it.

Press “Esc” for getting back to the command mode.

In the command mode:
Type “:q!” to just quit from the vim text editor without saving the file:

Type “:wq” and provide the file’s name for saving the file and quit from the VIM text editor.

To know more about the VIM commands and other techniques, do not hesitate to look at the man page of the VIM text editor.

$ man vim

Conclusion

This post provides a solution to an error “vim: command not found” that occurred in the CentOS 8 Machine. We have learned to install VIM on the CnetOS 8 system and also dive into a little bit of usage of the VIM text editor. VIM provides various functionalities apart from just letting a user write some text in a file.

About the author

Shehroz Azam

A Javascript Developer & Linux enthusiast with 4 years of industrial experience and proven know-how to combine creative and usability viewpoints resulting in world-class web applications. I have experience working with Vue, React & Node.js & currently working on article writing and video creation.