The “vim: command not found” error in Bash indicates that the “vim” command is either not installed or inaccessible. To fix this error, run:
sudo apt install -y vim
This error signifies difficulty in accessing the Vim text editor within the Bash environment. It typically arises when Vim is not installed or not included in the system’s PATH. So, installing Vim and configuring the system environment solves the problem in most cases. Let’s see all the possible solutions to this error.
Reasons for “vim” Command Not Found Error
Some common reasons for “vim” command not found error are:
- Incorrect Spelling: An error in command spelling raises the “command not found” error in Bash.
- Vim not Installed: If you are unable to use the “vim” command, it could be that your system does not have Vim installed.
- Incorrect Installation Path: The PATH on your system may not contain Vim.
- Inadequate Permissions: Vm might not have the authorization it needs to function.
- Sudo Configuration: If encountering the error with sudo, it might be due to the secure_path setting in the “sudoers” file.
2 Methods to Solve “bash: vim: command not found”
Follow the below methods to solve the vim command not found error in Bash:
1. Install “vim”
Most of the time, an incorrect installation of Vim on your system causes the “bash: vim: command not found” error. In this instance, APT in Ubuntu, YUM in RedHat, and Pacman in Arch Linux can install “vim” on your system with all its dependencies. To do that, follow the steps:
- Press CTRL+ALT+T to open the terminal.
- Run the command to install vim in Ubuntu:
sudo apt install -y vim
- Execute
vim
to verify the installation.
Now, the vim command is executed successfully and opened the Vim text editor.
2. Set “vim” PATH Variable
A prevalent reason behind the “vim command not found” is Vim is not present in your system PATH environment variables. To set the PATH variable for vim, follow the steps below:
- Press CTRL+ALT+T to open the terminal.
- Use which command to check the current path of Vim:
which vim
- Open bashrc file using:
nano ~/.bashrc
- Now, replace <path to vim> in
export PATH=$PATH:<path to vim>
code with the which command’s output and paste it at the end of the file. For example:export PATH=$PATH:/usr/bin/vim
- Press CTRL+S to save, and CTRL+X to exit.
- Then, execute the .bashrc file using:
source ~/.bashrc
- Now you can check running a vim command. For example:
vim –version
After adding the path, the vim command ran without raising any error.
Conclusion
In conclusion, resolving the “bash: vim: command not found” issue involves ensuring the installation of Vim and configuring the system’s PATH appropriately. Applying these solutions allows you to seamlessly access Vim commands within the Bash environment and unlock Vim’s powerful document editing capabilities.
People Also Ask
How to fix vim command not found in CentOS?
To fix the “vim: command not found” in CentOS, execute sudo dnf install vim
. Subsequently, to update the shell profile, open .bashrc file using nano ~/.bashrc
and add export PATH=$PATH:/usr/bin/vim
. After adding the line, either restart the terminal or run source ~/.bashrc
. Now, you can run vim
command.
How to fix vim command not found in RHEL?
To fix the “vim command not found” issue in Red Hat Enterprise Linux (RHEL), first, run sudo yum install vim
to install it. Then open the .bashrc file and add export PATH=$PATH:/usr/bin/vim
at the end. Finally, run source ~/.bashrc
to apply changes. Verify the installation by typing vim
in the terminal to ensure Vim is now accessible.
How to fix vim command not found in Arch Linux?
To fix the “vim: command not found” in Arch Linux, execute sudo pacman -S install vim
. Then, open .bashrc file and add export PATH=$PATH:/usr/bin/vim
. After adding the line, either restart the terminal or run source ~/.bashrc
. Now, you can run vim
command.
How to solve “sudo: vim: command not found”?
If you’re getting the “sudo: vim: command not found” error, it means that the vim text editor is not installed on your system, or it’s not in the system’s PATH for the user running the sudo command. To solve this error, install vim in your system using the package manager. If vim is installed but you still get the error, open ./bashrc file and add the line below:
export PATH=$PATH:[path to vim]
To get the [path to vim], run which vim
command.
Related Articles
- [Fixed] “bash: sudo: command not found” Error
- [Solved] Bash “yarn” Command Not Found Error
- [Solved] Bash “docker” Command Not Found Error
- [Fixed] “bash: ng: command not found” Error
- [Fixed] “bash: java: command not found” Error
- Solved “bash: yum: command not found” [RHEL, Fedora, CentOS]
- [Fixed] “bash: curl: command not found” Error
- [Solved] “bash: node: command not found” Error
- [Solved] “bash: code: command not found” Error
- [Fixed!] “systemctl command not found” Error in Linux
<< Go Back to [Solved] “bash: command not found” Error | Bash Error Handling and Debugging | Bash Scripting Tutorial
FUNDAMENTALS A Complete Guide for Beginners