The error message “vim: command not found” usually appears when you try to launch Vim from the terminal, but the system cannot locate the executable file. This typically means one of the two things; either Vim is not installed on your system or the system PATH.
While Vim comes pre-installed on many Linux distributions, there are some container based environments like Alpine, Docker images, or minimal cloud VMs) that leave it out to save some space. On macOS, Vim is usually pre-installed, but a custom shell environment or a broken PATH can still cause this error.
In this guide, we will learn the causes, issues, and troubleshooting FAQs to deeply understand the error.
What Causes the ‘vim command not found’ Error?
The “vim: command not found” error means that your system cannot locate the vim executable task when you execute it in the terminal. Here are some common causes of this error:
- Vim Is Not Installed
Many minimal Linux distributions, such as Alpine, Arch, or Docker containers do not include Vim by default. If it is not installed, the shell would not find it.
- Broken or Missing PATH
Even if Vim is already installed, the system won’t find it unless the directory is in the part of the PATH environment variable. An incomplete PATH can cause this error.
Get exclusive access to all things tech-savvy, and be the first to receive
the latest updates directly in your inbox.
- Corrupted Installation
If Vim was installed partially or removed improperly, the command will still appear to exist but fail to execute.
- Typing Error or Alias Conflict
Typing errors in Vim can also shadow the actual command, you can this line to check with:
type vim
- Using a Restricted Shell
Sometimes, in restricted environments, certain commands are unavailable, even if they are present in normal circumstances.
Check If Vim Is Installed
The first step to fix vim command not found error is to ensure that Vim is already present on your system. You can do by running the following command line:
Using which:
which vim
- If Vim is installed and in your PATH, this will return the full path (e.g., /usr/bin/vim).
- If not, it will return nothing.
Using command -v:
command -v vim
- This works similarly to which and is built into most shells.
- It’s a more portable way to check if a command is available.
If these checks confirm Vim isn’t installed, it’s time to install it based on your operating system. Here is how you can do it easily:
How to Install Vim Based on Your OS
If Vim is not already in your system, you can download it using your system’s package manager. Here is how you can install it on the most common platforms:
- Ubuntu/Debian
Use the apt package manager:

sudo apt update
sudo apt install vim
- Fedora
Use the dnf command:
sudo dnf install vim
- Arch Linux / Manjaro
Use pacman:
sudo pacman -S vim
- macOS (via Homebrew)
First, make sure Homebrew is installed. Then:
brew install vim
macOS comes with a basic version of Vim pre-installed. Installing via Homebrew gives you the latest version.
Once installed, you can confirm it’s working by running:
vim –version
Related Article: How to Install Linux: Your Pathway to an Enhanced Computing Experience
Using an Alternative: vi or neovim
If Vim is not available and you need to work quickly with another, you can fall back on these alternatives:
- vi (Very Common)
Most Unix-like systems use vi, a predecessor of Vim.
To use it:
vi filename
While Vi is not as competitive as Vim’s modern features, it is also a good option for basic editing tasks.
- Neovim
If you are more interested in an enhanced version of Vim, you can always fall back on Neovim, which prefers a better architecture.
To install on:
- Ubuntu/Debian:
sudo apt install neovim
- macOS (Homebrew):
brew install neovim
- Launch with:
nvim filename
Setting Vim as the Default Editor
You can also set Vim as the default browser on your system for easy access. You can do so by:
Temporarily (for current shell):
export EDITOR=vim
Permanently (add to your shell config):
Add this to your ~/.bashrc, ~/.zshrc, or equivalent:
export EDITOR=vim
Then, reload your shell:
source ~/.bashrc # or source ~/.zshrc
This ensures commands that rely on a default editor will use Vim.
Troubleshooting Guide For PATH Issues
Issue | What It Means | How to Fix It |
Vim is installed, but vimstill not found | The directory containing Vim isn’t in your $PATH. | Run echo $PATH to check. Add Vim’s path (e.g., /usr/bin) to your shell config. |
$PATH is empty or incomplete | Your environment may be misconfigured or reset. | Restore defaults or re-export the correct $PATH. |
Running Vim only works with full path | The executable exists (e.g., /usr/bin/vim) but isn’t globally recognized. | Create a symbolic link or add /usr/bin to your $PATH. |
Installed Vim via package manager, but terminal still can’t find it | Shell hasn’t been reloaded or the system needs a reboot. | Run hash -r, restart terminal, or reboot the system. |
Wrapping Up – Vim Command Not Found
Vim command not found error can occur due to multiple issues, however, the most common cause is definitely unclear PATH or incorrect installation of Vim. Both of these issues can be easily resolved with this guide!
Frequently Asked Questions
How do I install Vim on Linux?
You can install Vim by running sudo apt install vim
on Debian-based systems or sudo yum install vim
on RHEL-based systems.
Is Vim pre-installed on all Linux distributions?
No, while some distributions pre-install Vim, others may only include minimal editors like vi
or none at all.
Can I use alternatives if Vim is not available?
Yes, you can use editors like nano
, vi
, or install and configure other lightweight editors temporarily.