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:
Enable the EPEL repository if it is not enabled already using the command:
Upgrade the pre-installed packages as well to have fresh packages in the system:
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:
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:
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.
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.